From 11bdab7e61ad51217b2a8ed252997dd0652623c2 Mon Sep 17 00:00:00 2001 From: Leon Date: Sat, 24 Dec 2022 19:25:38 +1000 Subject: [PATCH] Change instances of `Value::string("foo", Span::test_data())` to `Value::test_string("foo")` (#7592) --- crates/nu-cli/src/reedline_config.rs | 22 +++++----- crates/nu-command/src/conversions/fmt.rs | 16 ++++---- .../nu-command/src/conversions/into/string.rs | 14 +++---- .../nu-command/src/core_commands/def_env.rs | 4 +- crates/nu-command/src/core_commands/export.rs | 4 +- .../src/core_commands/export_def.rs | 4 +- .../src/core_commands/export_def_env.rs | 4 +- .../src/core_commands/export_use.rs | 4 +- crates/nu-command/src/core_commands/module.rs | 8 ++-- .../src/core_commands/overlay/list.rs | 4 +- crates/nu-command/src/core_commands/use_.rs | 6 +-- .../nu-command/src/dataframe/eager/columns.rs | 5 +-- .../src/dataframe/expressions/as_nu.rs | 5 +-- .../src/dataframe/expressions/col.rs | 5 +-- .../src/dataframe/expressions/lit.rs | 5 +-- crates/nu-command/src/date/format.rs | 2 +- crates/nu-command/src/env/export_env.rs | 2 +- .../nu-command/src/experimental/is_admin.rs | 6 +-- .../src/experimental/view_source.rs | 14 +++---- crates/nu-command/src/filters/each.rs | 4 +- crates/nu-command/src/filters/each_while.rs | 6 +-- crates/nu-command/src/filters/par_each.rs | 2 +- crates/nu-command/src/formats/from/ini.rs | 5 +-- crates/nu-command/src/formats/from/ssv.rs | 4 +- crates/nu-command/src/formats/from/vcf.rs | 12 +++--- crates/nu-command/src/formats/from/xml.rs | 2 +- crates/nu-command/src/formats/from/yaml.rs | 4 +- .../src/strings/encode_decode/base64.rs | 14 +++---- .../strings/encode_decode/decode_base64.rs | 2 +- .../strings/encode_decode/encode_base64.rs | 4 +- .../src/strings/str_/case/camel_case.rs | 11 ++--- .../src/strings/str_/case/capitalize.rs | 9 ++--- .../src/strings/str_/case/downcase.rs | 14 ++----- .../src/strings/str_/case/kebab_case.rs | 11 ++--- .../src/strings/str_/case/pascal_case.rs | 11 ++--- .../strings/str_/case/screaming_snake_case.rs | 11 ++--- .../src/strings/str_/case/snake_case.rs | 11 ++--- .../src/strings/str_/case/title_case.rs | 9 ++--- crates/nu-command/src/strings/str_/collect.rs | 8 ++-- crates/nu-command/src/strings/str_/join.rs | 8 ++-- crates/nu-command/src/strings/str_/lpad.rs | 8 ++-- crates/nu-command/src/strings/str_/replace.rs | 24 +++++------ crates/nu-command/src/strings/str_/reverse.rs | 8 ++-- crates/nu-command/src/strings/str_/rpad.rs | 8 ++-- .../nu-command/src/strings/str_/substring.rs | 2 +- .../nu-command/src/strings/str_/trim/trim_.rs | 40 +++++++++---------- crates/nu-command/src/viewers/griddle.rs | 10 ++--- crates/nu-command/src/viewers/table.rs | 22 +++++----- crates/nu-protocol/tests/test_value.rs | 2 +- crates/nu_plugin_inc/src/inc.rs | 6 +-- 50 files changed, 191 insertions(+), 235 deletions(-) diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index c7cbffb08..43c9f2167 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -990,7 +990,7 @@ mod test { #[test] fn test_send_event() { let cols = vec!["send".to_string()]; - let vals = vec![Value::string("Enter", Span::test_data())]; + let vals = vec![Value::test_string("Enter")]; let span = Span::test_data(); let b = EventType::try_from_columns(&cols, &vals, &span).unwrap(); @@ -1010,7 +1010,7 @@ mod test { #[test] fn test_edit_event() { let cols = vec!["edit".to_string()]; - let vals = vec![Value::string("Clear", Span::test_data())]; + let vals = vec![Value::test_string("Clear")]; let span = Span::test_data(); let b = EventType::try_from_columns(&cols, &vals, &span).unwrap(); @@ -1034,8 +1034,8 @@ mod test { fn test_send_menu() { let cols = vec!["send".to_string(), "name".to_string()]; let vals = vec![ - Value::string("Menu", Span::test_data()), - Value::string("history_menu", Span::test_data()), + Value::test_string("Menu"), + Value::test_string("history_menu"), ]; let span = Span::test_data(); @@ -1061,8 +1061,8 @@ mod test { // Menu event let cols = vec!["send".to_string(), "name".to_string()]; let vals = vec![ - Value::string("Menu", Span::test_data()), - Value::string("history_menu", Span::test_data()), + Value::test_string("Menu"), + Value::test_string("history_menu"), ]; let menu_event = Value::Record { @@ -1073,7 +1073,7 @@ mod test { // Enter event let cols = vec!["send".to_string()]; - let vals = vec![Value::string("Enter", Span::test_data())]; + let vals = vec![Value::test_string("Enter")]; let enter_event = Value::Record { cols, @@ -1114,8 +1114,8 @@ mod test { // Menu event let cols = vec!["send".to_string(), "name".to_string()]; let vals = vec![ - Value::string("Menu", Span::test_data()), - Value::string("history_menu", Span::test_data()), + Value::test_string("Menu"), + Value::test_string("history_menu"), ]; let menu_event = Value::Record { @@ -1126,7 +1126,7 @@ mod test { // Enter event let cols = vec!["send".to_string()]; - let vals = vec![Value::string("Enter", Span::test_data())]; + let vals = vec![Value::test_string("Enter")]; let enter_event = Value::Record { cols, @@ -1154,7 +1154,7 @@ mod test { #[test] fn test_error() { let cols = vec!["not_exist".to_string()]; - let vals = vec![Value::string("Enter", Span::test_data())]; + let vals = vec![Value::test_string("Enter")]; let span = Span::test_data(); let b = EventType::try_from_columns(&cols, &vals, &span); diff --git a/crates/nu-command/src/conversions/fmt.rs b/crates/nu-command/src/conversions/fmt.rs index c16ad0827..42d8ea14d 100644 --- a/crates/nu-command/src/conversions/fmt.rs +++ b/crates/nu-command/src/conversions/fmt.rs @@ -44,14 +44,14 @@ impl Command for Fmt { "upperhex".into(), ], vals: vec![ - Value::string("0b101010", Span::test_data()), - Value::string("42", Span::test_data()), - Value::string("42", Span::test_data()), - Value::string("4.2e1", Span::test_data()), - Value::string("0x2a", Span::test_data()), - Value::string("0o52", Span::test_data()), - Value::string("4.2E1", Span::test_data()), - Value::string("0x2A", Span::test_data()), + Value::test_string("0b101010"), + Value::test_string("42"), + Value::test_string("42"), + Value::test_string("4.2e1"), + Value::test_string("0x2a"), + Value::test_string("0o52"), + Value::test_string("4.2E1"), + Value::test_string("0x2A"), ], span: Span::test_data(), }), diff --git a/crates/nu-command/src/conversions/into/string.rs b/crates/nu-command/src/conversions/into/string.rs index 977af8d3d..7771c7c3b 100644 --- a/crates/nu-command/src/conversions/into/string.rs +++ b/crates/nu-command/src/conversions/into/string.rs @@ -79,22 +79,22 @@ impl Command for SubCommand { Example { description: "convert integer to string and append three decimal places", example: "5 | into string -d 3", - result: Some(Value::string("5.000", Span::test_data())), + result: Some(Value::test_string("5.000")), }, Example { description: "convert decimal to string and round to nearest integer", example: "1.7 | into string -d 0", - result: Some(Value::string("2", Span::test_data())), + result: Some(Value::test_string("2")), }, Example { description: "convert decimal to string", example: "1.7 | into string -d 1", - result: Some(Value::string("1.7", Span::test_data())), + result: Some(Value::test_string("1.7")), }, Example { description: "convert decimal to string and limit to 2 decimals", example: "1.734 | into string -d 2", - result: Some(Value::string("1.73", Span::test_data())), + result: Some(Value::test_string("1.73")), }, Example { description: "try to convert decimal to string and provide negative decimal points", @@ -111,17 +111,17 @@ impl Command for SubCommand { Example { description: "convert decimal to string", example: "4.3 | into string", - result: Some(Value::string("4.3", Span::test_data())), + result: Some(Value::test_string("4.3")), }, Example { description: "convert string to string", example: "'1234' | into string", - result: Some(Value::string("1234", Span::test_data())), + result: Some(Value::test_string("1234")), }, Example { description: "convert boolean to string", example: "true | into string", - result: Some(Value::string("true", Span::test_data())), + result: Some(Value::test_string("true")), }, // TODO: This should work but does not; see https://github.com/nushell/nushell/issues/7032 // Example { diff --git a/crates/nu-command/src/core_commands/def_env.rs b/crates/nu-command/src/core_commands/def_env.rs index 7dbfeb181..da7ec5110 100644 --- a/crates/nu-command/src/core_commands/def_env.rs +++ b/crates/nu-command/src/core_commands/def_env.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value}; #[derive(Clone)] pub struct DefEnv; @@ -72,7 +72,7 @@ def-env cd_with_fallback [arg = ""] { vec![Example { description: "Set environment variable by call a custom command", example: r#"def-env foo [] { let-env BAR = "BAZ" }; foo; $env.BAR"#, - result: Some(Value::string("BAZ", Span::test_data())), + result: Some(Value::test_string("BAZ")), }] } } diff --git a/crates/nu-command/src/core_commands/export.rs b/crates/nu-command/src/core_commands/export.rs index a238a105c..656c9081d 100644 --- a/crates/nu-command/src/core_commands/export.rs +++ b/crates/nu-command/src/core_commands/export.rs @@ -2,7 +2,7 @@ use nu_engine::get_full_help; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Category, Example, IntoPipelineData, PipelineData, Signature, Span, Type, Value, + Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value, }; #[derive(Clone)] @@ -56,7 +56,7 @@ impl Command for ExportCommand { vec![Example { description: "Export a definition from a module", example: r#"module utils { export def my-command [] { "hello" } }; use utils my-command; my-command"#, - result: Some(Value::string("hello", Span::test_data())), + result: Some(Value::test_string("hello")), }] } diff --git a/crates/nu-command/src/core_commands/export_def.rs b/crates/nu-command/src/core_commands/export_def.rs index 3a48b5918..e56cf3bf4 100644 --- a/crates/nu-command/src/core_commands/export_def.rs +++ b/crates/nu-command/src/core_commands/export_def.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value}; #[derive(Clone)] pub struct ExportDef; @@ -46,7 +46,7 @@ impl Command for ExportDef { vec![Example { description: "Define a custom command in a module and call it", example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, - result: Some(Value::string("foo", Span::test_data())), + result: Some(Value::test_string("foo")), }] } diff --git a/crates/nu-command/src/core_commands/export_def_env.rs b/crates/nu-command/src/core_commands/export_def_env.rs index 345ae11e6..324458a29 100644 --- a/crates/nu-command/src/core_commands/export_def_env.rs +++ b/crates/nu-command/src/core_commands/export_def_env.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value}; #[derive(Clone)] pub struct ExportDefEnv; @@ -72,7 +72,7 @@ export def-env cd_with_fallback [arg = ""] { vec![Example { description: "Define a custom command that participates in the environment in a module and call it", example: r#"module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR"#, - result: Some(Value::string("BAZ", Span::test_data())), + result: Some(Value::test_string("BAZ")), }] } diff --git a/crates/nu-command/src/core_commands/export_use.rs b/crates/nu-command/src/core_commands/export_use.rs index 68e53eb20..56e7ca129 100644 --- a/crates/nu-command/src/core_commands/export_use.rs +++ b/crates/nu-command/src/core_commands/export_use.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value}; #[derive(Clone)] pub struct ExportUse; @@ -53,7 +53,7 @@ impl Command for ExportUse { use eggs foo foo "#, - result: Some(Value::string("foo", Span::test_data())), + result: Some(Value::test_string("foo")), }] } diff --git a/crates/nu-command/src/core_commands/module.rs b/crates/nu-command/src/core_commands/module.rs index 9b391bbe7..bf995b772 100644 --- a/crates/nu-command/src/core_commands/module.rs +++ b/crates/nu-command/src/core_commands/module.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value}; #[derive(Clone)] pub struct Module; @@ -46,17 +46,17 @@ impl Command for Module { Example { description: "Define a custom command in a module and call it", example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, - result: Some(Value::string("foo", Span::test_data())), + result: Some(Value::test_string("foo")), }, Example { description: "Define an environment variable in a module", example: r#"module foo { export-env { let-env FOO = "BAZ" } }; use foo; $env.FOO"#, - result: Some(Value::string("BAZ", Span::test_data())), + result: Some(Value::test_string("BAZ")), }, Example { description: "Define a custom command that participates in the environment in a module and call it", example: r#"module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR"#, - result: Some(Value::string("BAZ", Span::test_data())), + result: Some(Value::test_string("BAZ")), }, ] } diff --git a/crates/nu-command/src/core_commands/overlay/list.rs b/crates/nu-command/src/core_commands/overlay/list.rs index 7dec9b394..90af373d5 100644 --- a/crates/nu-command/src/core_commands/overlay/list.rs +++ b/crates/nu-command/src/core_commands/overlay/list.rs @@ -1,7 +1,7 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value, }; #[derive(Clone)] @@ -52,7 +52,7 @@ impl Command for OverlayList { example: r#"module spam { export def foo [] { "foo" } } overlay use spam overlay list | last"#, - result: Some(Value::string("spam", Span::test_data())), + result: Some(Value::test_string("spam")), }] } } diff --git a/crates/nu-command/src/core_commands/use_.rs b/crates/nu-command/src/core_commands/use_.rs index dd4e162c0..0a4ecaf45 100644 --- a/crates/nu-command/src/core_commands/use_.rs +++ b/crates/nu-command/src/core_commands/use_.rs @@ -2,7 +2,7 @@ use nu_engine::{eval_block, find_in_dirs_env, redirect_env}; use nu_protocol::ast::{Call, Expr, Expression}; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, + Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, }; #[derive(Clone)] @@ -122,12 +122,12 @@ impl Command for Use { Example { description: "Define a custom command in a module and call it", example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, - result: Some(Value::string("foo", Span::test_data())), + result: Some(Value::test_string("foo")), }, Example { description: "Define a custom command that participates in the environment in a module and call it", example: r#"module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR"#, - result: Some(Value::string("BAZ", Span::test_data())), + result: Some(Value::test_string("BAZ")), }, ] } diff --git a/crates/nu-command/src/dataframe/eager/columns.rs b/crates/nu-command/src/dataframe/eager/columns.rs index a5ba682fc..8a8760372 100644 --- a/crates/nu-command/src/dataframe/eager/columns.rs +++ b/crates/nu-command/src/dataframe/eager/columns.rs @@ -29,10 +29,7 @@ impl Command for ColumnsDF { description: "Dataframe columns", example: "[[a b]; [1 2] [3 4]] | into df | columns", result: Some(Value::List { - vals: vec![ - Value::string("a", Span::test_data()), - Value::string("b", Span::test_data()), - ], + vals: vec![Value::test_string("a"), Value::test_string("b")], span: Span::test_data(), }), }] diff --git a/crates/nu-command/src/dataframe/expressions/as_nu.rs b/crates/nu-command/src/dataframe/expressions/as_nu.rs index 3f581adb9..287b40994 100644 --- a/crates/nu-command/src/dataframe/expressions/as_nu.rs +++ b/crates/nu-command/src/dataframe/expressions/as_nu.rs @@ -31,10 +31,7 @@ impl Command for ExprAsNu { example: "col a | into nu", result: Some(Value::Record { cols: vec!["expr".into(), "value".into()], - vals: vec![ - Value::string("column", Span::test_data()), - Value::string("a", Span::test_data()), - ], + vals: vec![Value::test_string("column"), Value::test_string("a")], span: Span::test_data(), }), }] diff --git a/crates/nu-command/src/dataframe/expressions/col.rs b/crates/nu-command/src/dataframe/expressions/col.rs index 8fad129cb..8066e8f0b 100644 --- a/crates/nu-command/src/dataframe/expressions/col.rs +++ b/crates/nu-command/src/dataframe/expressions/col.rs @@ -37,10 +37,7 @@ impl Command for ExprCol { example: "col a | into nu", result: Some(Value::Record { cols: vec!["expr".into(), "value".into()], - vals: vec![ - Value::string("column", Span::test_data()), - Value::string("a", Span::test_data()), - ], + vals: vec![Value::test_string("column"), Value::test_string("a")], span: Span::test_data(), }), }] diff --git a/crates/nu-command/src/dataframe/expressions/lit.rs b/crates/nu-command/src/dataframe/expressions/lit.rs index 553195336..1468dc452 100644 --- a/crates/nu-command/src/dataframe/expressions/lit.rs +++ b/crates/nu-command/src/dataframe/expressions/lit.rs @@ -36,10 +36,7 @@ impl Command for ExprLit { example: "lit 2 | into nu", result: Some(Value::Record { cols: vec!["expr".into(), "value".into()], - vals: vec![ - Value::string("literal", Span::test_data()), - Value::string("2i64", Span::test_data()), - ], + vals: vec![Value::test_string("literal"), Value::test_string("2i64")], span: Span::test_data(), }), }] diff --git a/crates/nu-command/src/date/format.rs b/crates/nu-command/src/date/format.rs index 6d7c59a42..16b3470ea 100644 --- a/crates/nu-command/src/date/format.rs +++ b/crates/nu-command/src/date/format.rs @@ -107,7 +107,7 @@ impl Command for SubCommand { Example { description: "Format a given date using a given format string.", example: r#""2021-10-22 20:00:12 +01:00" | date format "%Y-%m-%d""#, - result: Some(Value::string("2021-10-22", Span::test_data())), + result: Some(Value::test_string("2021-10-22")), }, ] } diff --git a/crates/nu-command/src/env/export_env.rs b/crates/nu-command/src/env/export_env.rs index 69c967049..cde0f9814 100644 --- a/crates/nu-command/src/env/export_env.rs +++ b/crates/nu-command/src/env/export_env.rs @@ -65,7 +65,7 @@ impl Command for ExportEnv { Example { description: "Set an environment variable and examine its value", example: r#"export-env { let-env SPAM = 'eggs' }; $env.SPAM"#, - result: Some(Value::string("eggs", Span::test_data())), + result: Some(Value::test_string("eggs")), }, ] } diff --git a/crates/nu-command/src/experimental/is_admin.rs b/crates/nu-command/src/experimental/is_admin.rs index 4ba05763f..88d194b33 100644 --- a/crates/nu-command/src/experimental/is_admin.rs +++ b/crates/nu-command/src/experimental/is_admin.rs @@ -1,9 +1,7 @@ use is_root::is_root; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, Signature, Span, Type, Value, -}; +use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value}; #[derive(Clone)] pub struct IsAdmin; @@ -43,7 +41,7 @@ impl Command for IsAdmin { Example { description: "Return 'iamroot' if nushell is running with admin/root privileges, and 'iamnotroot' if not.", example: r#"if is-admin { "iamroot" } else { "iamnotroot" }"#, - result: Some(Value::string("iamnotroot", Span::test_data())), + result: Some(Value::test_string("iamnotroot")), }, ] } diff --git a/crates/nu-command/src/experimental/view_source.rs b/crates/nu-command/src/experimental/view_source.rs index b1a67ebf4..7647eabcc 100644 --- a/crates/nu-command/src/experimental/view_source.rs +++ b/crates/nu-command/src/experimental/view_source.rs @@ -3,8 +3,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, + Value, }; #[derive(Clone)] @@ -167,27 +167,27 @@ impl Command for ViewSource { Example { description: "View the source of a code block", example: r#"let abc = { echo 'hi' }; view-source $abc"#, - result: Some(Value::string("{ echo 'hi' }", Span::test_data())), + result: Some(Value::test_string("{ echo 'hi' }")), }, Example { description: "View the source of a custom command", example: r#"def hi [] { echo 'Hi!' }; view-source hi"#, - result: Some(Value::string("{ echo 'Hi!' }", Span::test_data())), + result: Some(Value::test_string("{ echo 'Hi!' }")), }, Example { description: "View the source of a custom command, which participates in the caller environment", example: r#"def-env foo [] { let-env BAR = 'BAZ' }; view-source foo"#, - result: Some(Value::string("{ let-env BAR = 'BAZ' }", Span::test_data())), + result: Some(Value::test_string("{ let-env BAR = 'BAZ' }")), }, Example { description: "View the source of a module", example: r#"module mod-foo { export-env { let-env FOO_ENV = 'BAZ' } }; view-source mod-foo"#, - result: Some(Value::string(" export-env { let-env FOO_ENV = 'BAZ' }", Span::test_data())), + result: Some(Value::test_string(" export-env { let-env FOO_ENV = 'BAZ' }")), }, Example { description: "View the source of an alias", example: r#"alias hello = echo hi; view-source hello"#, - result: Some(Value::string("echo hi", Span::test_data())), + result: Some(Value::test_string("echo hi")), }, ] } diff --git a/crates/nu-command/src/filters/each.rs b/crates/nu-command/src/filters/each.rs index 8f46fe2cd..23d578f90 100644 --- a/crates/nu-command/src/filters/each.rs +++ b/crates/nu-command/src/filters/each.rs @@ -64,7 +64,7 @@ with 'transpose' first."# Value::Nothing { span: Span::test_data(), }, - Value::string("found 2!", Span::test_data()), + Value::test_string("found 2!"), Value::Nothing { span: Span::test_data(), }, @@ -104,7 +104,7 @@ with 'transpose' first."# description: "Iterate over each element, producing a list showing indexes of any 2s", result: Some(Value::List { - vals: vec![Value::string("found 2 at 1!", Span::test_data())], + vals: vec![Value::test_string("found 2 at 1!")], span: Span::test_data(), }), }, diff --git a/crates/nu-command/src/filters/each_while.rs b/crates/nu-command/src/filters/each_while.rs index a226bb0e8..b1f10f950 100644 --- a/crates/nu-command/src/filters/each_while.rs +++ b/crates/nu-command/src/filters/each_while.rs @@ -47,8 +47,8 @@ impl Command for EachWhile { Value::int(4, Span::test_data()), ]; let stream_test_2 = vec![ - Value::string("Output: 1", Span::test_data()), - Value::string("Output: 2", Span::test_data()), + Value::test_string("Output: 1"), + Value::test_string("Output: 2"), ]; vec![ @@ -72,7 +72,7 @@ impl Command for EachWhile { example: r#"[1 2 3] | each while {|el ind| if $el < 2 { $"value ($el) at ($ind)!"} }"#, description: "Iterate over each element, printing the matching value and its index", result: Some(Value::List { - vals: vec![Value::string("value 1 at 0!", Span::test_data())], + vals: vec![Value::test_string("value 1 at 0!")], span: Span::test_data(), }), }, diff --git a/crates/nu-command/src/filters/par_each.rs b/crates/nu-command/src/filters/par_each.rs index 99766c1dc..d2f87b15d 100644 --- a/crates/nu-command/src/filters/par_each.rs +++ b/crates/nu-command/src/filters/par_each.rs @@ -52,7 +52,7 @@ impl Command for ParEach { example: r#"[1 2 3] | par-each -n { |it| if $it.item == 2 { $"found 2 at ($it.index)!"} }"#, description: "Iterate over each element, print the matching value and its index", result: Some(Value::List { - vals: vec![Value::string("found 2 at 1!", Span::test_data())], + vals: vec![Value::test_string("found 2 at 1!")], span: Span::test_data(), }), }, diff --git a/crates/nu-command/src/formats/from/ini.rs b/crates/nu-command/src/formats/from/ini.rs index b0f369a66..5d7689e54 100644 --- a/crates/nu-command/src/formats/from/ini.rs +++ b/crates/nu-command/src/formats/from/ini.rs @@ -33,10 +33,7 @@ b=2' | from ini", cols: vec!["foo".to_string()], vals: vec![Value::Record { cols: vec!["a".to_string(), "b".to_string()], - vals: vec![ - Value::string("1", Span::test_data()), - Value::string("2", Span::test_data()), - ], + vals: vec![Value::test_string("1"), Value::test_string("2")], span: Span::test_data(), }], span: Span::test_data(), diff --git a/crates/nu-command/src/formats/from/ssv.rs b/crates/nu-command/src/formats/from/ssv.rs index df93fd65f..2ade91b32 100644 --- a/crates/nu-command/src/formats/from/ssv.rs +++ b/crates/nu-command/src/formats/from/ssv.rs @@ -44,13 +44,13 @@ impl Command for FromSsv { example: r#"'FOO BAR 1 2' | from ssv"#, description: "Converts ssv formatted string to table", - result: Some(Value::List { vals: vec![Value::Record { cols: vec!["FOO".to_string(), "BAR".to_string()], vals: vec![Value::string("1", Span::test_data()), Value::string("2", Span::test_data())], span: Span::test_data() }], span: Span::test_data() }), + result: Some(Value::List { vals: vec![Value::Record { cols: vec!["FOO".to_string(), "BAR".to_string()], vals: vec![Value::test_string("1"), Value::test_string("2")], span: Span::test_data() }], span: Span::test_data() }), }, Example { example: r#"'FOO BAR 1 2' | from ssv -n"#, description: "Converts ssv formatted string to table but not treating the first row as column names", result: Some( - Value::List { vals: vec![Value::Record { cols: vec!["column1".to_string(), "column2".to_string()], vals: vec![Value::string("FOO", Span::test_data()), Value::string("BAR", Span::test_data())], span: Span::test_data() }, Value::Record { cols: vec!["column1".to_string(), "column2".to_string()], vals: vec![Value::string("1", Span::test_data()), Value::string("2", Span::test_data())], span: Span::test_data() }], span: Span::test_data() }), + Value::List { vals: vec![Value::Record { cols: vec!["column1".to_string(), "column2".to_string()], vals: vec![Value::test_string("FOO"), Value::test_string("BAR")], span: Span::test_data() }, Value::Record { cols: vec!["column1".to_string(), "column2".to_string()], vals: vec![Value::test_string("1"), Value::test_string("2")], span: Span::test_data() }], span: Span::test_data() }), }] } diff --git a/crates/nu-command/src/formats/from/vcf.rs b/crates/nu-command/src/formats/from/vcf.rs index fd441fc54..12820dc5f 100644 --- a/crates/nu-command/src/formats/from/vcf.rs +++ b/crates/nu-command/src/formats/from/vcf.rs @@ -57,8 +57,8 @@ END:VCARD' | from vcf", "params".to_string(), ], vals: vec![ - Value::string("N", Span::test_data()), - Value::string("Foo", Span::test_data()), + Value::test_string("N"), + Value::test_string("Foo"), Value::Nothing { span: Span::test_data(), }, @@ -72,8 +72,8 @@ END:VCARD' | from vcf", "params".to_string(), ], vals: vec![ - Value::string("FN", Span::test_data()), - Value::string("Bar", Span::test_data()), + Value::test_string("FN"), + Value::test_string("Bar"), Value::Nothing { span: Span::test_data(), }, @@ -87,8 +87,8 @@ END:VCARD' | from vcf", "params".to_string(), ], vals: vec![ - Value::string("EMAIL", Span::test_data()), - Value::string("foo@bar.com", Span::test_data()), + Value::test_string("EMAIL"), + Value::test_string("foo@bar.com"), Value::Nothing { span: Span::test_data(), }, diff --git a/crates/nu-command/src/formats/from/xml.rs b/crates/nu-command/src/formats/from/xml.rs index 6ed356b20..43c0bc8d5 100644 --- a/crates/nu-command/src/formats/from/xml.rs +++ b/crates/nu-command/src/formats/from/xml.rs @@ -54,7 +54,7 @@ impl Command for FromXml { cols: vec!["children".to_string(), "attributes".to_string()], vals: vec![ Value::List { - vals: vec![Value::string("Event", Span::test_data())], + vals: vec![Value::test_string("Event")], span: Span::test_data(), }, Value::Record { diff --git a/crates/nu-command/src/formats/from/yaml.rs b/crates/nu-command/src/formats/from/yaml.rs index e0624e54c..8601b58db 100644 --- a/crates/nu-command/src/formats/from/yaml.rs +++ b/crates/nu-command/src/formats/from/yaml.rs @@ -259,7 +259,7 @@ mod test { input: r#"value: "{{ something }}""#, expected: Ok(Value::Record { cols: vec!["value".to_string()], - vals: vec![Value::string("{{ something }}", Span::test_data())], + vals: vec![Value::test_string("{{ something }}")], span: Span::test_data(), }), }, @@ -268,7 +268,7 @@ mod test { input: r#"value: {{ something }}"#, expected: Ok(Value::Record { cols: vec!["value".to_string()], - vals: vec![Value::string("{{ something }}", Span::test_data())], + vals: vec![Value::test_string("{{ something }}")], span: Span::test_data(), }), }, diff --git a/crates/nu-command/src/strings/encode_decode/base64.rs b/crates/nu-command/src/strings/encode_decode/base64.rs index bd74dddcd..65673c3e5 100644 --- a/crates/nu-command/src/strings/encode_decode/base64.rs +++ b/crates/nu-command/src/strings/encode_decode/base64.rs @@ -180,8 +180,8 @@ mod tests { #[test] fn base64_encode_standard() { - let word = Value::string("Some Data Padding", Span::test_data()); - let expected = Value::string("U29tZSBEYXRhIFBhZGRpbmc=", Span::test_data()); + let word = Value::test_string("Some Data Padding"); + let expected = Value::test_string("U29tZSBEYXRhIFBhZGRpbmc="); let actual = action( &word, @@ -203,8 +203,8 @@ mod tests { #[test] fn base64_encode_standard_no_padding() { - let word = Value::string("Some Data Padding", Span::test_data()); - let expected = Value::string("U29tZSBEYXRhIFBhZGRpbmc", Span::test_data()); + let word = Value::test_string("Some Data Padding"); + let expected = Value::test_string("U29tZSBEYXRhIFBhZGRpbmc"); let actual = action( &word, @@ -226,8 +226,8 @@ mod tests { #[test] fn base64_encode_url_safe() { - let word = Value::string("this is for url", Span::test_data()); - let expected = Value::string("dGhpcyBpcyBmb3IgdXJs", Span::test_data()); + let word = Value::test_string("this is for url"); + let expected = Value::test_string("dGhpcyBpcyBmb3IgdXJs"); let actual = action( &word, @@ -299,7 +299,7 @@ mod tests { val: vec![77, 97, 110], span: Span::test_data(), }; - let expected = Value::string("TWFu", Span::test_data()); + let expected = Value::test_string("TWFu"); let actual = action( &word, diff --git a/crates/nu-command/src/strings/encode_decode/decode_base64.rs b/crates/nu-command/src/strings/encode_decode/decode_base64.rs index 44c4eeddc..4dcaee9e2 100644 --- a/crates/nu-command/src/strings/encode_decode/decode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/decode_base64.rs @@ -52,7 +52,7 @@ impl Command for DecodeBase64 { Example { description: "Base64 decode a value and output as UTF-8 string", example: "'U29tZSBEYXRh' | decode base64", - result: Some(Value::string("Some Data", Span::test_data())), + result: Some(Value::test_string("Some Data")), }, Example { description: "Base64 decode a value and output as binary", diff --git a/crates/nu-command/src/strings/encode_decode/encode_base64.rs b/crates/nu-command/src/strings/encode_decode/encode_base64.rs index c017cdd2f..31e02abda 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_base64.rs @@ -44,12 +44,12 @@ impl Command for EncodeBase64 { Example { description: "Encode binary data", example: "0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode base64", - result: Some(Value::string("CfkRAp1041vYQVbFY1aIwA==", Span::test_data())), + result: Some(Value::test_string("CfkRAp1041vYQVbFY1aIwA==")), }, Example { description: "Encode a string with default settings", example: "'Some Data' | encode base64", - result: Some(Value::string("U29tZSBEYXRh", Span::test_data())), + result: Some(Value::test_string("U29tZSBEYXRh")), }, Example { description: "Encode a string with the binhex character set", diff --git a/crates/nu-command/src/strings/str_/case/camel_case.rs b/crates/nu-command/src/strings/str_/case/camel_case.rs index d9c08f6a0..d3ed041a9 100644 --- a/crates/nu-command/src/strings/str_/case/camel_case.rs +++ b/crates/nu-command/src/strings/str_/case/camel_case.rs @@ -50,17 +50,17 @@ impl Command for SubCommand { Example { description: "convert a string to camelCase", example: " 'NuShell' | str camel-case", - result: Some(Value::string("nuShell", Span::test_data())), + result: Some(Value::test_string("nuShell")), }, Example { description: "convert a string to camelCase", example: "'this-is-the-first-case' | str camel-case", - result: Some(Value::string("thisIsTheFirstCase", Span::test_data())), + result: Some(Value::test_string("thisIsTheFirstCase")), }, Example { description: "convert a string to camelCase", example: " 'this_is_the_second_case' | str camel-case", - result: Some(Value::string("thisIsTheSecondCase", Span::test_data())), + result: Some(Value::test_string("thisIsTheSecondCase")), }, Example { description: "convert a column from a table to camelCase", @@ -69,10 +69,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("nuTest", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("nuTest"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/capitalize.rs b/crates/nu-command/src/strings/str_/case/capitalize.rs index 9728d1b7f..2f7c42053 100644 --- a/crates/nu-command/src/strings/str_/case/capitalize.rs +++ b/crates/nu-command/src/strings/str_/case/capitalize.rs @@ -48,12 +48,12 @@ impl Command for SubCommand { Example { description: "Capitalize contents", example: "'good day' | str capitalize", - result: Some(Value::string("Good day", Span::test_data())), + result: Some(Value::test_string("Good day")), }, Example { description: "Capitalize contents", example: "'anton' | str capitalize", - result: Some(Value::string("Anton", Span::test_data())), + result: Some(Value::test_string("Anton")), }, Example { description: "Capitalize a column in a table", @@ -62,10 +62,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("Nu_test", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("Nu_test"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/downcase.rs b/crates/nu-command/src/strings/str_/case/downcase.rs index 4f29539eb..9150b40d1 100644 --- a/crates/nu-command/src/strings/str_/case/downcase.rs +++ b/crates/nu-command/src/strings/str_/case/downcase.rs @@ -48,12 +48,12 @@ impl Command for SubCommand { Example { description: "Downcase contents", example: "'NU' | str downcase", - result: Some(Value::string("nu", Span::test_data())), + result: Some(Value::test_string("nu")), }, Example { description: "Downcase contents", example: "'TESTa' | str downcase", - result: Some(Value::string("testa", Span::test_data())), + result: Some(Value::test_string("testa")), }, Example { description: "Downcase contents", @@ -61,10 +61,7 @@ impl Command for SubCommand { result: Some(Value::List { vals: vec![Value::Record { cols: vec!["ColA".to_string(), "ColB".to_string()], - vals: vec![ - Value::string("test", Span::test_data()), - Value::string("ABC", Span::test_data()), - ], + vals: vec![Value::test_string("test"), Value::test_string("ABC")], span: Span::test_data(), }], span: Span::test_data(), @@ -76,10 +73,7 @@ impl Command for SubCommand { result: Some(Value::List { vals: vec![Value::Record { cols: vec!["ColA".to_string(), "ColB".to_string()], - vals: vec![ - Value::string("test", Span::test_data()), - Value::string("abc", Span::test_data()), - ], + vals: vec![Value::test_string("test"), Value::test_string("abc")], span: Span::test_data(), }], span: Span::test_data(), diff --git a/crates/nu-command/src/strings/str_/case/kebab_case.rs b/crates/nu-command/src/strings/str_/case/kebab_case.rs index fabad4934..9b215ecfd 100644 --- a/crates/nu-command/src/strings/str_/case/kebab_case.rs +++ b/crates/nu-command/src/strings/str_/case/kebab_case.rs @@ -50,17 +50,17 @@ impl Command for SubCommand { Example { description: "convert a string to kebab-case", example: "'NuShell' | str kebab-case", - result: Some(Value::string("nu-shell", Span::test_data())), + result: Some(Value::test_string("nu-shell")), }, Example { description: "convert a string to kebab-case", example: "'thisIsTheFirstCase' | str kebab-case", - result: Some(Value::string("this-is-the-first-case", Span::test_data())), + result: Some(Value::test_string("this-is-the-first-case")), }, Example { description: "convert a string to kebab-case", example: "'THIS_IS_THE_SECOND_CASE' | str kebab-case", - result: Some(Value::string("this-is-the-second-case", Span::test_data())), + result: Some(Value::test_string("this-is-the-second-case")), }, Example { description: "convert a column from a table to kebab-case", @@ -69,10 +69,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("nu-test", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("nu-test"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/pascal_case.rs b/crates/nu-command/src/strings/str_/case/pascal_case.rs index cda1e725c..49da88d02 100644 --- a/crates/nu-command/src/strings/str_/case/pascal_case.rs +++ b/crates/nu-command/src/strings/str_/case/pascal_case.rs @@ -50,17 +50,17 @@ impl Command for SubCommand { Example { description: "convert a string to PascalCase", example: "'nu-shell' | str pascal-case", - result: Some(Value::string("NuShell", Span::test_data())), + result: Some(Value::test_string("NuShell")), }, Example { description: "convert a string to PascalCase", example: "'this-is-the-first-case' | str pascal-case", - result: Some(Value::string("ThisIsTheFirstCase", Span::test_data())), + result: Some(Value::test_string("ThisIsTheFirstCase")), }, Example { description: "convert a string to PascalCase", example: "'this_is_the_second_case' | str pascal-case", - result: Some(Value::string("ThisIsTheSecondCase", Span::test_data())), + result: Some(Value::test_string("ThisIsTheSecondCase")), }, Example { description: "convert a column from a table to PascalCase", @@ -69,10 +69,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("NuTest", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("NuTest"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs index d6c79f408..6489da390 100644 --- a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs @@ -49,17 +49,17 @@ impl Command for SubCommand { Example { description: "convert a string to SCREAMING_SNAKE_CASE", example: r#" "NuShell" | str screaming-snake-case"#, - result: Some(Value::string("NU_SHELL", Span::test_data())), + result: Some(Value::test_string("NU_SHELL")), }, Example { description: "convert a string to SCREAMING_SNAKE_CASE", example: r#" "this_is_the_second_case" | str screaming-snake-case"#, - result: Some(Value::string("THIS_IS_THE_SECOND_CASE", Span::test_data())), + result: Some(Value::test_string("THIS_IS_THE_SECOND_CASE")), }, Example { description: "convert a string to SCREAMING_SNAKE_CASE", example: r#""this-is-the-first-case" | str screaming-snake-case"#, - result: Some(Value::string("THIS_IS_THE_FIRST_CASE", Span::test_data())), + result: Some(Value::test_string("THIS_IS_THE_FIRST_CASE")), }, Example { description: "convert a column from a table to SCREAMING_SNAKE_CASE", @@ -68,10 +68,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("NU_TEST", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("NU_TEST"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/snake_case.rs b/crates/nu-command/src/strings/str_/case/snake_case.rs index f9f15279a..61133d395 100644 --- a/crates/nu-command/src/strings/str_/case/snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/snake_case.rs @@ -49,17 +49,17 @@ impl Command for SubCommand { Example { description: "convert a string to snake_case", example: r#" "NuShell" | str snake-case"#, - result: Some(Value::string("nu_shell", Span::test_data())), + result: Some(Value::test_string("nu_shell")), }, Example { description: "convert a string to snake_case", example: r#" "this_is_the_second_case" | str snake-case"#, - result: Some(Value::string("this_is_the_second_case", Span::test_data())), + result: Some(Value::test_string("this_is_the_second_case")), }, Example { description: "convert a string to snake_case", example: r#""this-is-the-first-case" | str snake-case"#, - result: Some(Value::string("this_is_the_first_case", Span::test_data())), + result: Some(Value::test_string("this_is_the_first_case")), }, Example { description: "convert a column from a table to snake_case", @@ -68,10 +68,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["lang".to_string(), "gems".to_string()], - vals: vec![ - Value::string("nu_test", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("nu_test"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/case/title_case.rs b/crates/nu-command/src/strings/str_/case/title_case.rs index 31e4a37d8..6c42d03c2 100644 --- a/crates/nu-command/src/strings/str_/case/title_case.rs +++ b/crates/nu-command/src/strings/str_/case/title_case.rs @@ -50,12 +50,12 @@ impl Command for SubCommand { Example { description: "convert a string to Title Case", example: "'nu-shell' | str title-case", - result: Some(Value::string("Nu Shell", Span::test_data())), + result: Some(Value::test_string("Nu Shell")), }, Example { description: "convert a string to Title Case", example: "'this is a test case' | str title-case", - result: Some(Value::string("This Is A Test Case", Span::test_data())), + result: Some(Value::test_string("This Is A Test Case")), }, Example { description: "convert a column from a table to Title Case", @@ -64,10 +64,7 @@ impl Command for SubCommand { vals: vec![Value::Record { span: Span::test_data(), cols: vec!["title".to_string(), "count".to_string()], - vals: vec![ - Value::string("Nu Test", Span::test_data()), - Value::test_int(100), - ], + vals: vec![Value::test_string("Nu Test"), Value::test_int(100)], }], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/collect.rs b/crates/nu-command/src/strings/str_/collect.rs index f77904e64..a5832cdf0 100644 --- a/crates/nu-command/src/strings/str_/collect.rs +++ b/crates/nu-command/src/strings/str_/collect.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, + Value, }; #[derive(Clone)] @@ -74,12 +74,12 @@ impl Command for StrCollect { Example { description: "Create a string from input", example: "['nu', 'shell'] | str collect", - result: Some(Value::string("nushell", Span::test_data())), + result: Some(Value::test_string("nushell")), }, Example { description: "Create a string from input with a separator", example: "['nu', 'shell'] | str collect '-'", - result: Some(Value::string("nu-shell", Span::test_data())), + result: Some(Value::test_string("nu-shell")), }, ] } diff --git a/crates/nu-command/src/strings/str_/join.rs b/crates/nu-command/src/strings/str_/join.rs index 1ffe12ba8..ea8fe7f81 100644 --- a/crates/nu-command/src/strings/str_/join.rs +++ b/crates/nu-command/src/strings/str_/join.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type, + Value, }; #[derive(Clone)] @@ -78,12 +78,12 @@ impl Command for StrJoin { Example { description: "Create a string from input", example: "['nu', 'shell'] | str join", - result: Some(Value::string("nushell", Span::test_data())), + result: Some(Value::test_string("nushell")), }, Example { description: "Create a string from input with a separator", example: "['nu', 'shell'] | str join '-'", - result: Some(Value::string("nu-shell", Span::test_data())), + result: Some(Value::test_string("nu-shell")), }, ] } diff --git a/crates/nu-command/src/strings/str_/lpad.rs b/crates/nu-command/src/strings/str_/lpad.rs index 540801e76..a4d65fa40 100644 --- a/crates/nu-command/src/strings/str_/lpad.rs +++ b/crates/nu-command/src/strings/str_/lpad.rs @@ -82,22 +82,22 @@ impl Command for SubCommand { Example { description: "Left-pad a string with asterisks until it's 10 characters wide", example: "'nushell' | str lpad -l 10 -c '*'", - result: Some(Value::string("***nushell", Span::test_data())), + result: Some(Value::test_string("***nushell")), }, Example { description: "Left-pad a string with zeroes until it's 10 character wide", example: "'123' | str lpad -l 10 -c '0'", - result: Some(Value::string("0000000123", Span::test_data())), + result: Some(Value::test_string("0000000123")), }, Example { description: "Use lpad to truncate a string to its last three characters", example: "'123456789' | str lpad -l 3 -c '0'", - result: Some(Value::string("789", Span::test_data())), + result: Some(Value::test_string("789")), }, Example { description: "Use lpad to pad Unicode", example: "'▉' | str lpad -l 10 -c '▉'", - result: Some(Value::string("▉▉▉▉▉▉▉▉▉▉", Span::test_data())), + result: Some(Value::test_string("▉▉▉▉▉▉▉▉▉▉")), }, ] } diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 5676eeb8c..e351a74c1 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -94,12 +94,12 @@ impl Command for SubCommand { Example { description: "Find and replace contents with capture group", example: "'my_library.rb' | str replace '(.+).rb' '$1.nu'", - result: Some(Value::string("my_library.nu", Span::test_data())), + result: Some(Value::test_string("my_library.nu")), }, Example { description: "Find and replace all occurrences of find string", example: "'abc abc abc' | str replace -a 'b' 'z'", - result: Some(Value::string("azc azc azc", Span::test_data())), + result: Some(Value::test_string("azc azc azc")), }, Example { description: "Find and replace all occurrences of find string in table", @@ -109,9 +109,9 @@ impl Command for SubCommand { vals: vec![Value::Record { cols: vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()], vals: vec![ - Value::string("azc", Span::test_data()), - Value::string("abc", Span::test_data()), - Value::string("ads", Span::test_data()), + Value::test_string("azc"), + Value::test_string("abc"), + Value::test_string("ads"), ], span: Span::test_data(), }], @@ -121,27 +121,27 @@ impl Command for SubCommand { Example { description: "Find and replace contents without using the replace parameter as a regular expression", example: r#"'dogs_$1_cats' | str replace '\$1' '$2' -n"#, - result: Some(Value::string("dogs_$2_cats", Span::test_data())), + result: Some(Value::test_string("dogs_$2_cats")), }, Example { description: "Find and replace the first occurence using string replacement *not* regular expressions", example: r#"'c:\some\cool\path' | str replace 'c:\some\cool' '~' -s"#, - result: Some(Value::string("~\\path", Span::test_data())), + result: Some(Value::test_string("~\\path")), }, Example { description: "Find and replace all occurences using string replacement *not* regular expressions", example: r#"'abc abc abc' | str replace -a 'b' 'z' -s"#, - result: Some(Value::string("azc azc azc", Span::test_data())), + result: Some(Value::test_string("azc azc azc")), }, Example { description: "Find and replace with fancy-regex", example: r#"'a sucessful b' | str replace '\b([sS])uc(?:cs|s?)e(ed(?:ed|ing|s?)|ss(?:es|ful(?:ly)?|i(?:ons?|ve(?:ly)?)|ors?)?)\b' '${1}ucce$2'"#, - result: Some(Value::string("a successful b", Span::test_data())), + result: Some(Value::test_string("a successful b")), }, Example { description: "Find and replace with fancy-regex", example: r#"'GHIKK-9+*' | str replace '[*[:xdigit:]+]' 'z'"#, - result: Some(Value::string("GHIKK-z+*", Span::test_data())), + result: Some(Value::test_string("GHIKK-z+*")), }, ] @@ -252,7 +252,7 @@ mod tests { #[test] fn can_have_capture_groups() { - let word = Value::string("Cargo.toml", Span::test_data()); + let word = Value::test_string("Cargo.toml"); let options = Arguments { find: test_spanned_string("Cargo.(.+)"), @@ -264,6 +264,6 @@ mod tests { }; let actual = action(&word, &options, Span::test_data()); - assert_eq!(actual, Value::string("Carga.toml", Span::test_data())); + assert_eq!(actual, Value::test_string("Carga.toml")); } } diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index bd67a495a..f7db72989 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -51,16 +51,16 @@ impl Command for SubCommand { Example { description: "Reverse a single string", example: "'Nushell' | str reverse", - result: Some(Value::string("llehsuN", Span::test_data())), + result: Some(Value::test_string("llehsuN")), }, Example { description: "Reverse multiple strings in a list", example: "['Nushell' 'is' 'cool'] | str reverse", result: Some(Value::List { vals: vec![ - Value::string("llehsuN", Span::test_data()), - Value::string("si", Span::test_data()), - Value::string("looc", Span::test_data()), + Value::test_string("llehsuN"), + Value::test_string("si"), + Value::test_string("looc"), ], span: Span::test_data(), }), diff --git a/crates/nu-command/src/strings/str_/rpad.rs b/crates/nu-command/src/strings/str_/rpad.rs index 97dc53dd7..1631b908b 100644 --- a/crates/nu-command/src/strings/str_/rpad.rs +++ b/crates/nu-command/src/strings/str_/rpad.rs @@ -82,22 +82,22 @@ impl Command for SubCommand { Example { description: "Right-pad a string with asterisks until it's 10 characters wide", example: "'nushell' | str rpad -l 10 -c '*'", - result: Some(Value::string("nushell***", Span::test_data())), + result: Some(Value::test_string("nushell***")), }, Example { description: "Right-pad a string with zeroes until it's 10 characters wide", example: "'123' | str rpad -l 10 -c '0'", - result: Some(Value::string("1230000000", Span::test_data())), + result: Some(Value::test_string("1230000000")), }, Example { description: "Use rpad to truncate a string to its first three characters", example: "'123456789' | str rpad -l 3 -c '0'", - result: Some(Value::string("123", Span::test_data())), + result: Some(Value::test_string("123")), }, Example { description: "Use rpad to pad Unicode", example: "'▉' | str rpad -l 10 -c '▉'", - result: Some(Value::string("▉▉▉▉▉▉▉▉▉▉", Span::test_data())), + result: Some(Value::test_string("▉▉▉▉▉▉▉▉▉▉")), }, ] } diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index 793e36dcf..d72dec784 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -294,7 +294,7 @@ mod tests { #[test] fn substrings_indexes() { - let word = Value::string("andres", Span::test_data()); + let word = Value::test_string("andres"); let cases = vec![ expectation("a", (0, 1)), diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index 8c8e7ee40..4011d3d80 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -476,17 +476,17 @@ mod tests { fn global_trims_table_all_white_space() { let row = Value::List { vals: vec![ - Value::string(" nu shell ", Span::test_data()), + Value::test_string(" nu shell "), Value::int(65, Span::test_data()), - Value::string(" d", Span::test_data()), + Value::test_string(" d"), ], span: Span::test_data(), }; let expected = Value::List { vals: vec![ - Value::string("nushell", Span::test_data()), + Value::test_string("nushell"), Value::int(65, Span::test_data()), - Value::string("d", Span::test_data()), + Value::test_string("d"), ], span: Span::test_data(), }; @@ -548,17 +548,17 @@ mod tests { fn global_trims_table_all_custom_character() { let row = Value::List { vals: vec![ - Value::string("##nu####shell##", Span::test_data()), + Value::test_string("##nu####shell##"), Value::int(65, Span::test_data()), - Value::string("#d", Span::test_data()), + Value::test_string("#d"), ], span: Span::test_data(), }; let expected = Value::List { vals: vec![ - Value::string("nushell", Span::test_data()), + Value::test_string("nushell"), Value::int(65, Span::test_data()), - Value::string("d", Span::test_data()), + Value::test_string("d"), ], span: Span::test_data(), }; @@ -658,17 +658,17 @@ mod tests { fn global_trim_left_table() { let row = Value::List { vals: vec![ - Value::string(" a ", Span::test_data()), + Value::test_string(" a "), Value::int(65, Span::test_data()), - Value::string(" d", Span::test_data()), + Value::test_string(" d"), ], span: Span::test_data(), }; let expected = Value::List { vals: vec![ - Value::string("a ", Span::test_data()), + Value::test_string("a "), Value::int(65, Span::test_data()), - Value::string("d", Span::test_data()), + Value::test_string("d"), ], span: Span::test_data(), }; @@ -783,17 +783,17 @@ mod tests { fn global_trim_right_table() { let row = Value::List { vals: vec![ - Value::string(" a ", Span::test_data()), + Value::test_string(" a "), Value::int(65, Span::test_data()), - Value::string(" d", Span::test_data()), + Value::test_string(" d"), ], span: Span::test_data(), }; let expected = Value::List { vals: vec![ - Value::string(" a", Span::test_data()), + Value::test_string(" a"), Value::int(65, Span::test_data()), - Value::string(" d", Span::test_data()), + Value::test_string(" d"), ], span: Span::test_data(), }; @@ -910,17 +910,17 @@ mod tests { fn global_trim_format_flag_table() { let row = Value::List { vals: vec![ - Value::string(" a b c d ", Span::test_data()), + Value::test_string(" a b c d "), Value::int(65, Span::test_data()), - Value::string(" b c d e f", Span::test_data()), + Value::test_string(" b c d e f"), ], span: Span::test_data(), }; let expected = Value::List { vals: vec![ - Value::string("a b c d", Span::test_data()), + Value::test_string("a b c d"), Value::int(65, Span::test_data()), - Value::string("b c d e f", Span::test_data()), + Value::test_string("b c d e f"), ], span: Span::test_data(), }; diff --git a/crates/nu-command/src/viewers/griddle.rs b/crates/nu-command/src/viewers/griddle.rs index 5d1f9fdd2..edd5beab5 100644 --- a/crates/nu-command/src/viewers/griddle.rs +++ b/crates/nu-command/src/viewers/griddle.rs @@ -140,27 +140,27 @@ prints out the list properly."# Example { description: "Render a simple list to a grid", example: "[1 2 3 a b c] | grid", - result: Some(Value::string("1 │ 2 │ 3 │ a │ b │ c\n", Span::test_data())), + result: Some(Value::test_string("1 │ 2 │ 3 │ a │ b │ c\n")), }, Example { description: "The above example is the same as:", example: "[1 2 3 a b c] | wrap name | grid", - result: Some(Value::string("1 │ 2 │ 3 │ a │ b │ c\n", Span::test_data())), + result: Some(Value::test_string("1 │ 2 │ 3 │ a │ b │ c\n")), }, Example { description: "Render a record to a grid", example: "{name: 'foo', b: 1, c: 2} | grid", - result: Some(Value::string("foo\n", Span::test_data())), + result: Some(Value::test_string("foo\n")), }, Example { description: "Render a list of records to a grid", example: "[{name: 'A', v: 1} {name: 'B', v: 2} {name: 'C', v: 3}] | grid", - result: Some(Value::string("A │ B │ C\n", Span::test_data())), + result: Some(Value::test_string("A │ B │ C\n")), }, Example { description: "Render a table with 'name' column in it to a grid", example: "[[name patch]; [0.1.0 false] [0.1.1 true] [0.2.0 false]] | grid", - result: Some(Value::string("0.1.0 │ 0.1.1 │ 0.2.0\n", Span::test_data())), + result: Some(Value::test_string("0.1.0 │ 0.1.1 │ 0.2.0\n")), }, ] } diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 72b6be893..3843619fe 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -356,17 +356,17 @@ fn handle_table_command( fn supported_table_modes() -> Vec { vec![ - Value::string("basic", Span::test_data()), - Value::string("compact", Span::test_data()), - Value::string("compact_double", Span::test_data()), - Value::string("default", Span::test_data()), - Value::string("heavy", Span::test_data()), - Value::string("light", Span::test_data()), - Value::string("none", Span::test_data()), - Value::string("reinforced", Span::test_data()), - Value::string("rounded", Span::test_data()), - Value::string("thin", Span::test_data()), - Value::string("with_love", Span::test_data()), + Value::test_string("basic"), + Value::test_string("compact"), + Value::test_string("compact_double"), + Value::test_string("default"), + Value::test_string("heavy"), + Value::test_string("light"), + Value::test_string("none"), + Value::test_string("reinforced"), + Value::test_string("rounded"), + Value::test_string("thin"), + Value::test_string("with_love"), ] } diff --git a/crates/nu-protocol/tests/test_value.rs b/crates/nu-protocol/tests/test_value.rs index 05ff5b24a..b14fc7a9c 100644 --- a/crates/nu-protocol/tests/test_value.rs +++ b/crates/nu-protocol/tests/test_value.rs @@ -4,7 +4,7 @@ use nu_protocol::{Span, Value}; fn test_comparison_nothing() { let values = vec![ Value::int(1, Span::test_data()), - Value::string("string", Span::test_data()), + Value::test_string("string"), Value::float(1.0, Span::test_data()), ]; diff --git a/crates/nu_plugin_inc/src/inc.rs b/crates/nu_plugin_inc/src/inc.rs index 1018aed39..f12e48c51 100644 --- a/crates/nu_plugin_inc/src/inc.rs +++ b/crates/nu_plugin_inc/src/inc.rs @@ -120,7 +120,7 @@ mod tests { #[test] fn major() { - let expected = Value::string("1.0.0", Span::test_data()); + let expected = Value::test_string("1.0.0"); let mut inc = Inc::new(); inc.for_semver(SemVerAction::Major); assert_eq!(inc.apply("0.1.3", Span::test_data()), expected) @@ -128,7 +128,7 @@ mod tests { #[test] fn minor() { - let expected = Value::string("0.2.0", Span::test_data()); + let expected = Value::test_string("0.2.0"); let mut inc = Inc::new(); inc.for_semver(SemVerAction::Minor); assert_eq!(inc.apply("0.1.3", Span::test_data()), expected) @@ -136,7 +136,7 @@ mod tests { #[test] fn patch() { - let expected = Value::string("0.1.4", Span::test_data()); + let expected = Value::test_string("0.1.4"); let mut inc = Inc::new(); inc.for_semver(SemVerAction::Patch); assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)