Change instances of Value::string("foo", Span::test_data()) to Value::test_string("foo") (#7592)

This commit is contained in:
Leon 2022-12-24 19:25:38 +10:00 committed by GitHub
parent 3d682fe957
commit 11bdab7e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 191 additions and 235 deletions

View File

@ -990,7 +990,7 @@ mod test {
#[test] #[test]
fn test_send_event() { fn test_send_event() {
let cols = vec!["send".to_string()]; 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 span = Span::test_data();
let b = EventType::try_from_columns(&cols, &vals, &span).unwrap(); let b = EventType::try_from_columns(&cols, &vals, &span).unwrap();
@ -1010,7 +1010,7 @@ mod test {
#[test] #[test]
fn test_edit_event() { fn test_edit_event() {
let cols = vec!["edit".to_string()]; 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 span = Span::test_data();
let b = EventType::try_from_columns(&cols, &vals, &span).unwrap(); let b = EventType::try_from_columns(&cols, &vals, &span).unwrap();
@ -1034,8 +1034,8 @@ mod test {
fn test_send_menu() { fn test_send_menu() {
let cols = vec!["send".to_string(), "name".to_string()]; let cols = vec!["send".to_string(), "name".to_string()];
let vals = vec![ let vals = vec![
Value::string("Menu", Span::test_data()), Value::test_string("Menu"),
Value::string("history_menu", Span::test_data()), Value::test_string("history_menu"),
]; ];
let span = Span::test_data(); let span = Span::test_data();
@ -1061,8 +1061,8 @@ mod test {
// Menu event // Menu event
let cols = vec!["send".to_string(), "name".to_string()]; let cols = vec!["send".to_string(), "name".to_string()];
let vals = vec![ let vals = vec![
Value::string("Menu", Span::test_data()), Value::test_string("Menu"),
Value::string("history_menu", Span::test_data()), Value::test_string("history_menu"),
]; ];
let menu_event = Value::Record { let menu_event = Value::Record {
@ -1073,7 +1073,7 @@ mod test {
// Enter event // Enter event
let cols = vec!["send".to_string()]; 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 { let enter_event = Value::Record {
cols, cols,
@ -1114,8 +1114,8 @@ mod test {
// Menu event // Menu event
let cols = vec!["send".to_string(), "name".to_string()]; let cols = vec!["send".to_string(), "name".to_string()];
let vals = vec![ let vals = vec![
Value::string("Menu", Span::test_data()), Value::test_string("Menu"),
Value::string("history_menu", Span::test_data()), Value::test_string("history_menu"),
]; ];
let menu_event = Value::Record { let menu_event = Value::Record {
@ -1126,7 +1126,7 @@ mod test {
// Enter event // Enter event
let cols = vec!["send".to_string()]; 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 { let enter_event = Value::Record {
cols, cols,
@ -1154,7 +1154,7 @@ mod test {
#[test] #[test]
fn test_error() { fn test_error() {
let cols = vec!["not_exist".to_string()]; 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 span = Span::test_data();
let b = EventType::try_from_columns(&cols, &vals, &span); let b = EventType::try_from_columns(&cols, &vals, &span);

View File

@ -44,14 +44,14 @@ impl Command for Fmt {
"upperhex".into(), "upperhex".into(),
], ],
vals: vec![ vals: vec![
Value::string("0b101010", Span::test_data()), Value::test_string("0b101010"),
Value::string("42", Span::test_data()), Value::test_string("42"),
Value::string("42", Span::test_data()), Value::test_string("42"),
Value::string("4.2e1", Span::test_data()), Value::test_string("4.2e1"),
Value::string("0x2a", Span::test_data()), Value::test_string("0x2a"),
Value::string("0o52", Span::test_data()), Value::test_string("0o52"),
Value::string("4.2E1", Span::test_data()), Value::test_string("4.2E1"),
Value::string("0x2A", Span::test_data()), Value::test_string("0x2A"),
], ],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -79,22 +79,22 @@ impl Command for SubCommand {
Example { Example {
description: "convert integer to string and append three decimal places", description: "convert integer to string and append three decimal places",
example: "5 | into string -d 3", example: "5 | into string -d 3",
result: Some(Value::string("5.000", Span::test_data())), result: Some(Value::test_string("5.000")),
}, },
Example { Example {
description: "convert decimal to string and round to nearest integer", description: "convert decimal to string and round to nearest integer",
example: "1.7 | into string -d 0", example: "1.7 | into string -d 0",
result: Some(Value::string("2", Span::test_data())), result: Some(Value::test_string("2")),
}, },
Example { Example {
description: "convert decimal to string", description: "convert decimal to string",
example: "1.7 | into string -d 1", example: "1.7 | into string -d 1",
result: Some(Value::string("1.7", Span::test_data())), result: Some(Value::test_string("1.7")),
}, },
Example { Example {
description: "convert decimal to string and limit to 2 decimals", description: "convert decimal to string and limit to 2 decimals",
example: "1.734 | into string -d 2", example: "1.734 | into string -d 2",
result: Some(Value::string("1.73", Span::test_data())), result: Some(Value::test_string("1.73")),
}, },
Example { Example {
description: "try to convert decimal to string and provide negative decimal points", description: "try to convert decimal to string and provide negative decimal points",
@ -111,17 +111,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert decimal to string", description: "convert decimal to string",
example: "4.3 | into string", example: "4.3 | into string",
result: Some(Value::string("4.3", Span::test_data())), result: Some(Value::test_string("4.3")),
}, },
Example { Example {
description: "convert string to string", description: "convert string to string",
example: "'1234' | into string", example: "'1234' | into string",
result: Some(Value::string("1234", Span::test_data())), result: Some(Value::test_string("1234")),
}, },
Example { Example {
description: "convert boolean to string", description: "convert boolean to string",
example: "true | into 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 // TODO: This should work but does not; see https://github.com/nushell/nushell/issues/7032
// Example { // Example {

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; 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)] #[derive(Clone)]
pub struct DefEnv; pub struct DefEnv;
@ -72,7 +72,7 @@ def-env cd_with_fallback [arg = ""] {
vec![Example { vec![Example {
description: "Set environment variable by call a custom command", description: "Set environment variable by call a custom command",
example: r#"def-env foo [] { let-env BAR = "BAZ" }; foo; $env.BAR"#, 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")),
}] }]
} }
} }

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,
engine::{Command, EngineState, Stack}, engine::{Command, EngineState, Stack},
Category, Example, IntoPipelineData, PipelineData, Signature, Span, Type, Value, Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -56,7 +56,7 @@ impl Command for ExportCommand {
vec![Example { vec![Example {
description: "Export a definition from a module", description: "Export a definition from a module",
example: r#"module utils { export def my-command [] { "hello" } }; use utils my-command; my-command"#, 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")),
}] }]
} }

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; 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)] #[derive(Clone)]
pub struct ExportDef; pub struct ExportDef;
@ -46,7 +46,7 @@ impl Command for ExportDef {
vec![Example { vec![Example {
description: "Define a custom command in a module and call it", description: "Define a custom command in a module and call it",
example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, 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")),
}] }]
} }

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; 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)] #[derive(Clone)]
pub struct ExportDefEnv; pub struct ExportDefEnv;
@ -72,7 +72,7 @@ export def-env cd_with_fallback [arg = ""] {
vec![Example { vec![Example {
description: "Define a custom command that participates in the environment in a module and call it", 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"#, 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")),
}] }]
} }

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; 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)] #[derive(Clone)]
pub struct ExportUse; pub struct ExportUse;
@ -53,7 +53,7 @@ impl Command for ExportUse {
use eggs foo use eggs foo
foo foo
"#, "#,
result: Some(Value::string("foo", Span::test_data())), result: Some(Value::test_string("foo")),
}] }]
} }

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; 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)] #[derive(Clone)]
pub struct Module; pub struct Module;
@ -46,17 +46,17 @@ impl Command for Module {
Example { Example {
description: "Define a custom command in a module and call it", description: "Define a custom command in a module and call it",
example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, 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 { Example {
description: "Define an environment variable in a module", description: "Define an environment variable in a module",
example: r#"module foo { export-env { let-env FOO = "BAZ" } }; use foo; $env.FOO"#, 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 { Example {
description: "Define a custom command that participates in the environment in a module and call it", 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"#, 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")),
}, },
] ]
} }

View File

@ -1,7 +1,7 @@
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -52,7 +52,7 @@ impl Command for OverlayList {
example: r#"module spam { export def foo [] { "foo" } } example: r#"module spam { export def foo [] { "foo" } }
overlay use spam overlay use spam
overlay list | last"#, overlay list | last"#,
result: Some(Value::string("spam", Span::test_data())), result: Some(Value::test_string("spam")),
}] }]
} }
} }

View File

@ -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::ast::{Call, Expr, Expression};
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -122,12 +122,12 @@ impl Command for Use {
Example { Example {
description: "Define a custom command in a module and call it", description: "Define a custom command in a module and call it",
example: r#"module spam { export def foo [] { "foo" } }; use spam foo; foo"#, 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 { Example {
description: "Define a custom command that participates in the environment in a module and call it", 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"#, 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")),
}, },
] ]
} }

View File

@ -29,10 +29,7 @@ impl Command for ColumnsDF {
description: "Dataframe columns", description: "Dataframe columns",
example: "[[a b]; [1 2] [3 4]] | into df | columns", example: "[[a b]; [1 2] [3 4]] | into df | columns",
result: Some(Value::List { result: Some(Value::List {
vals: vec![ vals: vec![Value::test_string("a"), Value::test_string("b")],
Value::string("a", Span::test_data()),
Value::string("b", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}), }),
}] }]

View File

@ -31,10 +31,7 @@ impl Command for ExprAsNu {
example: "col a | into nu", example: "col a | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![Value::test_string("column"), Value::test_string("a")],
Value::string("column", Span::test_data()),
Value::string("a", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}), }),
}] }]

View File

@ -37,10 +37,7 @@ impl Command for ExprCol {
example: "col a | into nu", example: "col a | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![Value::test_string("column"), Value::test_string("a")],
Value::string("column", Span::test_data()),
Value::string("a", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}), }),
}] }]

View File

@ -36,10 +36,7 @@ impl Command for ExprLit {
example: "lit 2 | into nu", example: "lit 2 | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![Value::test_string("literal"), Value::test_string("2i64")],
Value::string("literal", Span::test_data()),
Value::string("2i64", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}), }),
}] }]

View File

@ -107,7 +107,7 @@ impl Command for SubCommand {
Example { Example {
description: "Format a given date using a given format string.", 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""#, 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")),
}, },
] ]
} }

View File

@ -65,7 +65,7 @@ impl Command for ExportEnv {
Example { Example {
description: "Set an environment variable and examine its value", description: "Set an environment variable and examine its value",
example: r#"export-env { let-env SPAM = 'eggs' }; $env.SPAM"#, example: r#"export-env { let-env SPAM = 'eggs' }; $env.SPAM"#,
result: Some(Value::string("eggs", Span::test_data())), result: Some(Value::test_string("eggs")),
}, },
] ]
} }

View File

@ -1,9 +1,7 @@
use is_root::is_root; use is_root::is_root;
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value};
Category, Example, IntoPipelineData, PipelineData, Signature, Span, Type, Value,
};
#[derive(Clone)] #[derive(Clone)]
pub struct IsAdmin; pub struct IsAdmin;
@ -43,7 +41,7 @@ impl Command for IsAdmin {
Example { Example {
description: "Return 'iamroot' if nushell is running with admin/root privileges, and 'iamnotroot' if not.", description: "Return 'iamroot' if nushell is running with admin/root privileges, and 'iamnotroot' if not.",
example: r#"if is-admin { "iamroot" } else { "iamnotroot" }"#, example: r#"if is-admin { "iamroot" } else { "iamnotroot" }"#,
result: Some(Value::string("iamnotroot", Span::test_data())), result: Some(Value::test_string("iamnotroot")),
}, },
] ]
} }

View File

@ -3,8 +3,8 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type,
Type, Value, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -167,27 +167,27 @@ impl Command for ViewSource {
Example { Example {
description: "View the source of a code block", description: "View the source of a code block",
example: r#"let abc = { echo 'hi' }; view-source $abc"#, 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 { Example {
description: "View the source of a custom command", description: "View the source of a custom command",
example: r#"def hi [] { echo 'Hi!' }; view-source hi"#, 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 { Example {
description: "View the source of a custom command, which participates in the caller environment", 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"#, 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 { Example {
description: "View the source of a module", description: "View the source of a module",
example: r#"module mod-foo { export-env { let-env FOO_ENV = 'BAZ' } }; view-source mod-foo"#, 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 { Example {
description: "View the source of an alias", description: "View the source of an alias",
example: r#"alias hello = echo hi; view-source hello"#, 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")),
}, },
] ]
} }

View File

@ -64,7 +64,7 @@ with 'transpose' first."#
Value::Nothing { Value::Nothing {
span: Span::test_data(), span: Span::test_data(),
}, },
Value::string("found 2!", Span::test_data()), Value::test_string("found 2!"),
Value::Nothing { Value::Nothing {
span: Span::test_data(), span: Span::test_data(),
}, },
@ -104,7 +104,7 @@ with 'transpose' first."#
description: description:
"Iterate over each element, producing a list showing indexes of any 2s", "Iterate over each element, producing a list showing indexes of any 2s",
result: Some(Value::List { 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(), span: Span::test_data(),
}), }),
}, },

View File

@ -47,8 +47,8 @@ impl Command for EachWhile {
Value::int(4, Span::test_data()), Value::int(4, Span::test_data()),
]; ];
let stream_test_2 = vec![ let stream_test_2 = vec![
Value::string("Output: 1", Span::test_data()), Value::test_string("Output: 1"),
Value::string("Output: 2", Span::test_data()), Value::test_string("Output: 2"),
]; ];
vec![ 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)!"} }"#, 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", description: "Iterate over each element, printing the matching value and its index",
result: Some(Value::List { 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(), span: Span::test_data(),
}), }),
}, },

View File

@ -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)!"} }"#, 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", description: "Iterate over each element, print the matching value and its index",
result: Some(Value::List { 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(), span: Span::test_data(),
}), }),
}, },

View File

@ -33,10 +33,7 @@ b=2' | from ini",
cols: vec!["foo".to_string()], cols: vec!["foo".to_string()],
vals: vec![Value::Record { vals: vec![Value::Record {
cols: vec!["a".to_string(), "b".to_string()], cols: vec!["a".to_string(), "b".to_string()],
vals: vec![ vals: vec![Value::test_string("1"), Value::test_string("2")],
Value::string("1", Span::test_data()),
Value::string("2", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}], }],
span: Span::test_data(), span: Span::test_data(),

View File

@ -44,13 +44,13 @@ impl Command for FromSsv {
example: r#"'FOO BAR example: r#"'FOO BAR
1 2' | from ssv"#, 1 2' | from ssv"#,
description: "Converts ssv formatted string to table", 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 {
example: r#"'FOO BAR example: r#"'FOO BAR
1 2' | from ssv -n"#, 1 2' | from ssv -n"#,
description: "Converts ssv formatted string to table but not treating the first row as column names", description: "Converts ssv formatted string to table but not treating the first row as column names",
result: Some( 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() }),
}] }]
} }

View File

@ -57,8 +57,8 @@ END:VCARD' | from vcf",
"params".to_string(), "params".to_string(),
], ],
vals: vec![ vals: vec![
Value::string("N", Span::test_data()), Value::test_string("N"),
Value::string("Foo", Span::test_data()), Value::test_string("Foo"),
Value::Nothing { Value::Nothing {
span: Span::test_data(), span: Span::test_data(),
}, },
@ -72,8 +72,8 @@ END:VCARD' | from vcf",
"params".to_string(), "params".to_string(),
], ],
vals: vec![ vals: vec![
Value::string("FN", Span::test_data()), Value::test_string("FN"),
Value::string("Bar", Span::test_data()), Value::test_string("Bar"),
Value::Nothing { Value::Nothing {
span: Span::test_data(), span: Span::test_data(),
}, },
@ -87,8 +87,8 @@ END:VCARD' | from vcf",
"params".to_string(), "params".to_string(),
], ],
vals: vec![ vals: vec![
Value::string("EMAIL", Span::test_data()), Value::test_string("EMAIL"),
Value::string("foo@bar.com", Span::test_data()), Value::test_string("foo@bar.com"),
Value::Nothing { Value::Nothing {
span: Span::test_data(), span: Span::test_data(),
}, },

View File

@ -54,7 +54,7 @@ impl Command for FromXml {
cols: vec!["children".to_string(), "attributes".to_string()], cols: vec!["children".to_string(), "attributes".to_string()],
vals: vec![ vals: vec![
Value::List { Value::List {
vals: vec![Value::string("Event", Span::test_data())], vals: vec![Value::test_string("Event")],
span: Span::test_data(), span: Span::test_data(),
}, },
Value::Record { Value::Record {

View File

@ -259,7 +259,7 @@ mod test {
input: r#"value: "{{ something }}""#, input: r#"value: "{{ something }}""#,
expected: Ok(Value::Record { expected: Ok(Value::Record {
cols: vec!["value".to_string()], cols: vec!["value".to_string()],
vals: vec![Value::string("{{ something }}", Span::test_data())], vals: vec![Value::test_string("{{ something }}")],
span: Span::test_data(), span: Span::test_data(),
}), }),
}, },
@ -268,7 +268,7 @@ mod test {
input: r#"value: {{ something }}"#, input: r#"value: {{ something }}"#,
expected: Ok(Value::Record { expected: Ok(Value::Record {
cols: vec!["value".to_string()], cols: vec!["value".to_string()],
vals: vec![Value::string("{{ something }}", Span::test_data())], vals: vec![Value::test_string("{{ something }}")],
span: Span::test_data(), span: Span::test_data(),
}), }),
}, },

View File

@ -180,8 +180,8 @@ mod tests {
#[test] #[test]
fn base64_encode_standard() { fn base64_encode_standard() {
let word = Value::string("Some Data Padding", Span::test_data()); let word = Value::test_string("Some Data Padding");
let expected = Value::string("U29tZSBEYXRhIFBhZGRpbmc=", Span::test_data()); let expected = Value::test_string("U29tZSBEYXRhIFBhZGRpbmc=");
let actual = action( let actual = action(
&word, &word,
@ -203,8 +203,8 @@ mod tests {
#[test] #[test]
fn base64_encode_standard_no_padding() { fn base64_encode_standard_no_padding() {
let word = Value::string("Some Data Padding", Span::test_data()); let word = Value::test_string("Some Data Padding");
let expected = Value::string("U29tZSBEYXRhIFBhZGRpbmc", Span::test_data()); let expected = Value::test_string("U29tZSBEYXRhIFBhZGRpbmc");
let actual = action( let actual = action(
&word, &word,
@ -226,8 +226,8 @@ mod tests {
#[test] #[test]
fn base64_encode_url_safe() { fn base64_encode_url_safe() {
let word = Value::string("this is for url", Span::test_data()); let word = Value::test_string("this is for url");
let expected = Value::string("dGhpcyBpcyBmb3IgdXJs", Span::test_data()); let expected = Value::test_string("dGhpcyBpcyBmb3IgdXJs");
let actual = action( let actual = action(
&word, &word,
@ -299,7 +299,7 @@ mod tests {
val: vec![77, 97, 110], val: vec![77, 97, 110],
span: Span::test_data(), span: Span::test_data(),
}; };
let expected = Value::string("TWFu", Span::test_data()); let expected = Value::test_string("TWFu");
let actual = action( let actual = action(
&word, &word,

View File

@ -52,7 +52,7 @@ impl Command for DecodeBase64 {
Example { Example {
description: "Base64 decode a value and output as UTF-8 string", description: "Base64 decode a value and output as UTF-8 string",
example: "'U29tZSBEYXRh' | decode base64", example: "'U29tZSBEYXRh' | decode base64",
result: Some(Value::string("Some Data", Span::test_data())), result: Some(Value::test_string("Some Data")),
}, },
Example { Example {
description: "Base64 decode a value and output as binary", description: "Base64 decode a value and output as binary",

View File

@ -44,12 +44,12 @@ impl Command for EncodeBase64 {
Example { Example {
description: "Encode binary data", description: "Encode binary data",
example: "0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode base64", 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 { Example {
description: "Encode a string with default settings", description: "Encode a string with default settings",
example: "'Some Data' | encode base64", example: "'Some Data' | encode base64",
result: Some(Value::string("U29tZSBEYXRh", Span::test_data())), result: Some(Value::test_string("U29tZSBEYXRh")),
}, },
Example { Example {
description: "Encode a string with the binhex character set", description: "Encode a string with the binhex character set",

View File

@ -50,17 +50,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to camelCase", description: "convert a string to camelCase",
example: " 'NuShell' | str camel-case", example: " 'NuShell' | str camel-case",
result: Some(Value::string("nuShell", Span::test_data())), result: Some(Value::test_string("nuShell")),
}, },
Example { Example {
description: "convert a string to camelCase", description: "convert a string to camelCase",
example: "'this-is-the-first-case' | str camel-case", example: "'this-is-the-first-case' | str camel-case",
result: Some(Value::string("thisIsTheFirstCase", Span::test_data())), result: Some(Value::test_string("thisIsTheFirstCase")),
}, },
Example { Example {
description: "convert a string to camelCase", description: "convert a string to camelCase",
example: " 'this_is_the_second_case' | str camel-case", example: " 'this_is_the_second_case' | str camel-case",
result: Some(Value::string("thisIsTheSecondCase", Span::test_data())), result: Some(Value::test_string("thisIsTheSecondCase")),
}, },
Example { Example {
description: "convert a column from a table to camelCase", description: "convert a column from a table to camelCase",
@ -69,10 +69,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("nuTest"), Value::test_int(100)],
Value::string("nuTest", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -48,12 +48,12 @@ impl Command for SubCommand {
Example { Example {
description: "Capitalize contents", description: "Capitalize contents",
example: "'good day' | str capitalize", example: "'good day' | str capitalize",
result: Some(Value::string("Good day", Span::test_data())), result: Some(Value::test_string("Good day")),
}, },
Example { Example {
description: "Capitalize contents", description: "Capitalize contents",
example: "'anton' | str capitalize", example: "'anton' | str capitalize",
result: Some(Value::string("Anton", Span::test_data())), result: Some(Value::test_string("Anton")),
}, },
Example { Example {
description: "Capitalize a column in a table", description: "Capitalize a column in a table",
@ -62,10 +62,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("Nu_test"), Value::test_int(100)],
Value::string("Nu_test", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -48,12 +48,12 @@ impl Command for SubCommand {
Example { Example {
description: "Downcase contents", description: "Downcase contents",
example: "'NU' | str downcase", example: "'NU' | str downcase",
result: Some(Value::string("nu", Span::test_data())), result: Some(Value::test_string("nu")),
}, },
Example { Example {
description: "Downcase contents", description: "Downcase contents",
example: "'TESTa' | str downcase", example: "'TESTa' | str downcase",
result: Some(Value::string("testa", Span::test_data())), result: Some(Value::test_string("testa")),
}, },
Example { Example {
description: "Downcase contents", description: "Downcase contents",
@ -61,10 +61,7 @@ impl Command for SubCommand {
result: Some(Value::List { result: Some(Value::List {
vals: vec![Value::Record { vals: vec![Value::Record {
cols: vec!["ColA".to_string(), "ColB".to_string()], cols: vec!["ColA".to_string(), "ColB".to_string()],
vals: vec![ vals: vec![Value::test_string("test"), Value::test_string("ABC")],
Value::string("test", Span::test_data()),
Value::string("ABC", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}], }],
span: Span::test_data(), span: Span::test_data(),
@ -76,10 +73,7 @@ impl Command for SubCommand {
result: Some(Value::List { result: Some(Value::List {
vals: vec![Value::Record { vals: vec![Value::Record {
cols: vec!["ColA".to_string(), "ColB".to_string()], cols: vec!["ColA".to_string(), "ColB".to_string()],
vals: vec![ vals: vec![Value::test_string("test"), Value::test_string("abc")],
Value::string("test", Span::test_data()),
Value::string("abc", Span::test_data()),
],
span: Span::test_data(), span: Span::test_data(),
}], }],
span: Span::test_data(), span: Span::test_data(),

View File

@ -50,17 +50,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to kebab-case", description: "convert a string to kebab-case",
example: "'NuShell' | str kebab-case", example: "'NuShell' | str kebab-case",
result: Some(Value::string("nu-shell", Span::test_data())), result: Some(Value::test_string("nu-shell")),
}, },
Example { Example {
description: "convert a string to kebab-case", description: "convert a string to kebab-case",
example: "'thisIsTheFirstCase' | str 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 { Example {
description: "convert a string to kebab-case", description: "convert a string to kebab-case",
example: "'THIS_IS_THE_SECOND_CASE' | str 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 { Example {
description: "convert a column from a table to kebab-case", description: "convert a column from a table to kebab-case",
@ -69,10 +69,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("nu-test"), Value::test_int(100)],
Value::string("nu-test", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -50,17 +50,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to PascalCase", description: "convert a string to PascalCase",
example: "'nu-shell' | str pascal-case", example: "'nu-shell' | str pascal-case",
result: Some(Value::string("NuShell", Span::test_data())), result: Some(Value::test_string("NuShell")),
}, },
Example { Example {
description: "convert a string to PascalCase", description: "convert a string to PascalCase",
example: "'this-is-the-first-case' | str pascal-case", example: "'this-is-the-first-case' | str pascal-case",
result: Some(Value::string("ThisIsTheFirstCase", Span::test_data())), result: Some(Value::test_string("ThisIsTheFirstCase")),
}, },
Example { Example {
description: "convert a string to PascalCase", description: "convert a string to PascalCase",
example: "'this_is_the_second_case' | str pascal-case", example: "'this_is_the_second_case' | str pascal-case",
result: Some(Value::string("ThisIsTheSecondCase", Span::test_data())), result: Some(Value::test_string("ThisIsTheSecondCase")),
}, },
Example { Example {
description: "convert a column from a table to PascalCase", description: "convert a column from a table to PascalCase",
@ -69,10 +69,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("NuTest"), Value::test_int(100)],
Value::string("NuTest", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -49,17 +49,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to SCREAMING_SNAKE_CASE", description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#" "NuShell" | str 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 { Example {
description: "convert a string to SCREAMING_SNAKE_CASE", description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#" "this_is_the_second_case" | str 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 { Example {
description: "convert a string to SCREAMING_SNAKE_CASE", description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#""this-is-the-first-case" | str 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 { Example {
description: "convert a column from a table to SCREAMING_SNAKE_CASE", description: "convert a column from a table to SCREAMING_SNAKE_CASE",
@ -68,10 +68,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("NU_TEST"), Value::test_int(100)],
Value::string("NU_TEST", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -49,17 +49,17 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to snake_case", description: "convert a string to snake_case",
example: r#" "NuShell" | str 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 { Example {
description: "convert a string to snake_case", description: "convert a string to snake_case",
example: r#" "this_is_the_second_case" | str 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 { Example {
description: "convert a string to snake_case", description: "convert a string to snake_case",
example: r#""this-is-the-first-case" | str 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 { Example {
description: "convert a column from a table to snake_case", description: "convert a column from a table to snake_case",
@ -68,10 +68,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["lang".to_string(), "gems".to_string()], cols: vec!["lang".to_string(), "gems".to_string()],
vals: vec![ vals: vec![Value::test_string("nu_test"), Value::test_int(100)],
Value::string("nu_test", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -50,12 +50,12 @@ impl Command for SubCommand {
Example { Example {
description: "convert a string to Title Case", description: "convert a string to Title Case",
example: "'nu-shell' | str 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 { Example {
description: "convert a string to Title Case", description: "convert a string to Title Case",
example: "'this is a test case' | str 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 { Example {
description: "convert a column from a table to Title Case", description: "convert a column from a table to Title Case",
@ -64,10 +64,7 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
span: Span::test_data(), span: Span::test_data(),
cols: vec!["title".to_string(), "count".to_string()], cols: vec!["title".to_string(), "count".to_string()],
vals: vec![ vals: vec![Value::test_string("Nu Test"), Value::test_int(100)],
Value::string("Nu Test", Span::test_data()),
Value::test_int(100),
],
}], }],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -2,8 +2,8 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type,
Type, Value, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -74,12 +74,12 @@ impl Command for StrCollect {
Example { Example {
description: "Create a string from input", description: "Create a string from input",
example: "['nu', 'shell'] | str collect", example: "['nu', 'shell'] | str collect",
result: Some(Value::string("nushell", Span::test_data())), result: Some(Value::test_string("nushell")),
}, },
Example { Example {
description: "Create a string from input with a separator", description: "Create a string from input with a separator",
example: "['nu', 'shell'] | str collect '-'", example: "['nu', 'shell'] | str collect '-'",
result: Some(Value::string("nu-shell", Span::test_data())), result: Some(Value::test_string("nu-shell")),
}, },
] ]
} }

View File

@ -2,8 +2,8 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{ use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type,
Type, Value, Value,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -78,12 +78,12 @@ impl Command for StrJoin {
Example { Example {
description: "Create a string from input", description: "Create a string from input",
example: "['nu', 'shell'] | str join", example: "['nu', 'shell'] | str join",
result: Some(Value::string("nushell", Span::test_data())), result: Some(Value::test_string("nushell")),
}, },
Example { Example {
description: "Create a string from input with a separator", description: "Create a string from input with a separator",
example: "['nu', 'shell'] | str join '-'", example: "['nu', 'shell'] | str join '-'",
result: Some(Value::string("nu-shell", Span::test_data())), result: Some(Value::test_string("nu-shell")),
}, },
] ]
} }

View File

@ -82,22 +82,22 @@ impl Command for SubCommand {
Example { Example {
description: "Left-pad a string with asterisks until it's 10 characters wide", description: "Left-pad a string with asterisks until it's 10 characters wide",
example: "'nushell' | str lpad -l 10 -c '*'", example: "'nushell' | str lpad -l 10 -c '*'",
result: Some(Value::string("***nushell", Span::test_data())), result: Some(Value::test_string("***nushell")),
}, },
Example { Example {
description: "Left-pad a string with zeroes until it's 10 character wide", description: "Left-pad a string with zeroes until it's 10 character wide",
example: "'123' | str lpad -l 10 -c '0'", example: "'123' | str lpad -l 10 -c '0'",
result: Some(Value::string("0000000123", Span::test_data())), result: Some(Value::test_string("0000000123")),
}, },
Example { Example {
description: "Use lpad to truncate a string to its last three characters", description: "Use lpad to truncate a string to its last three characters",
example: "'123456789' | str lpad -l 3 -c '0'", example: "'123456789' | str lpad -l 3 -c '0'",
result: Some(Value::string("789", Span::test_data())), result: Some(Value::test_string("789")),
}, },
Example { Example {
description: "Use lpad to pad Unicode", description: "Use lpad to pad Unicode",
example: "'▉' | str lpad -l 10 -c '▉'", example: "'▉' | str lpad -l 10 -c '▉'",
result: Some(Value::string("▉▉▉▉▉▉▉▉▉▉", Span::test_data())), result: Some(Value::test_string("▉▉▉▉▉▉▉▉▉▉")),
}, },
] ]
} }

View File

@ -94,12 +94,12 @@ impl Command for SubCommand {
Example { Example {
description: "Find and replace contents with capture group", description: "Find and replace contents with capture group",
example: "'my_library.rb' | str replace '(.+).rb' '$1.nu'", 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 { Example {
description: "Find and replace all occurrences of find string", description: "Find and replace all occurrences of find string",
example: "'abc abc abc' | str replace -a 'b' 'z'", 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 { Example {
description: "Find and replace all occurrences of find string in table", description: "Find and replace all occurrences of find string in table",
@ -109,9 +109,9 @@ impl Command for SubCommand {
vals: vec![Value::Record { vals: vec![Value::Record {
cols: vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()], cols: vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()],
vals: vec![ vals: vec![
Value::string("azc", Span::test_data()), Value::test_string("azc"),
Value::string("abc", Span::test_data()), Value::test_string("abc"),
Value::string("ads", Span::test_data()), Value::test_string("ads"),
], ],
span: Span::test_data(), span: Span::test_data(),
}], }],
@ -121,27 +121,27 @@ impl Command for SubCommand {
Example { Example {
description: "Find and replace contents without using the replace parameter as a regular expression", description: "Find and replace contents without using the replace parameter as a regular expression",
example: r#"'dogs_$1_cats' | str replace '\$1' '$2' -n"#, 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 { Example {
description: "Find and replace the first occurence using string replacement *not* regular expressions", 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"#, 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 { Example {
description: "Find and replace all occurences using string replacement *not* regular expressions", description: "Find and replace all occurences using string replacement *not* regular expressions",
example: r#"'abc abc abc' | str replace -a 'b' 'z' -s"#, 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 { Example {
description: "Find and replace with fancy-regex", 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'"#, 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 { Example {
description: "Find and replace with fancy-regex", description: "Find and replace with fancy-regex",
example: r#"'GHIKK-9+*' | str replace '[*[:xdigit:]+]' 'z'"#, 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] #[test]
fn can_have_capture_groups() { fn can_have_capture_groups() {
let word = Value::string("Cargo.toml", Span::test_data()); let word = Value::test_string("Cargo.toml");
let options = Arguments { let options = Arguments {
find: test_spanned_string("Cargo.(.+)"), find: test_spanned_string("Cargo.(.+)"),
@ -264,6 +264,6 @@ mod tests {
}; };
let actual = action(&word, &options, Span::test_data()); 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"));
} }
} }

View File

@ -51,16 +51,16 @@ impl Command for SubCommand {
Example { Example {
description: "Reverse a single string", description: "Reverse a single string",
example: "'Nushell' | str reverse", example: "'Nushell' | str reverse",
result: Some(Value::string("llehsuN", Span::test_data())), result: Some(Value::test_string("llehsuN")),
}, },
Example { Example {
description: "Reverse multiple strings in a list", description: "Reverse multiple strings in a list",
example: "['Nushell' 'is' 'cool'] | str reverse", example: "['Nushell' 'is' 'cool'] | str reverse",
result: Some(Value::List { result: Some(Value::List {
vals: vec![ vals: vec![
Value::string("llehsuN", Span::test_data()), Value::test_string("llehsuN"),
Value::string("si", Span::test_data()), Value::test_string("si"),
Value::string("looc", Span::test_data()), Value::test_string("looc"),
], ],
span: Span::test_data(), span: Span::test_data(),
}), }),

View File

@ -82,22 +82,22 @@ impl Command for SubCommand {
Example { Example {
description: "Right-pad a string with asterisks until it's 10 characters wide", description: "Right-pad a string with asterisks until it's 10 characters wide",
example: "'nushell' | str rpad -l 10 -c '*'", example: "'nushell' | str rpad -l 10 -c '*'",
result: Some(Value::string("nushell***", Span::test_data())), result: Some(Value::test_string("nushell***")),
}, },
Example { Example {
description: "Right-pad a string with zeroes until it's 10 characters wide", description: "Right-pad a string with zeroes until it's 10 characters wide",
example: "'123' | str rpad -l 10 -c '0'", example: "'123' | str rpad -l 10 -c '0'",
result: Some(Value::string("1230000000", Span::test_data())), result: Some(Value::test_string("1230000000")),
}, },
Example { Example {
description: "Use rpad to truncate a string to its first three characters", description: "Use rpad to truncate a string to its first three characters",
example: "'123456789' | str rpad -l 3 -c '0'", example: "'123456789' | str rpad -l 3 -c '0'",
result: Some(Value::string("123", Span::test_data())), result: Some(Value::test_string("123")),
}, },
Example { Example {
description: "Use rpad to pad Unicode", description: "Use rpad to pad Unicode",
example: "'▉' | str rpad -l 10 -c '▉'", example: "'▉' | str rpad -l 10 -c '▉'",
result: Some(Value::string("▉▉▉▉▉▉▉▉▉▉", Span::test_data())), result: Some(Value::test_string("▉▉▉▉▉▉▉▉▉▉")),
}, },
] ]
} }

View File

@ -294,7 +294,7 @@ mod tests {
#[test] #[test]
fn substrings_indexes() { fn substrings_indexes() {
let word = Value::string("andres", Span::test_data()); let word = Value::test_string("andres");
let cases = vec![ let cases = vec![
expectation("a", (0, 1)), expectation("a", (0, 1)),

View File

@ -476,17 +476,17 @@ mod tests {
fn global_trims_table_all_white_space() { fn global_trims_table_all_white_space() {
let row = Value::List { let row = Value::List {
vals: vec![ vals: vec![
Value::string(" nu shell ", Span::test_data()), Value::test_string(" nu shell "),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string(" d", Span::test_data()), Value::test_string(" d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
let expected = Value::List { let expected = Value::List {
vals: vec![ vals: vec![
Value::string("nushell", Span::test_data()), Value::test_string("nushell"),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string("d", Span::test_data()), Value::test_string("d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
@ -548,17 +548,17 @@ mod tests {
fn global_trims_table_all_custom_character() { fn global_trims_table_all_custom_character() {
let row = Value::List { let row = Value::List {
vals: vec![ vals: vec![
Value::string("##nu####shell##", Span::test_data()), Value::test_string("##nu####shell##"),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string("#d", Span::test_data()), Value::test_string("#d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
let expected = Value::List { let expected = Value::List {
vals: vec![ vals: vec![
Value::string("nushell", Span::test_data()), Value::test_string("nushell"),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string("d", Span::test_data()), Value::test_string("d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
@ -658,17 +658,17 @@ mod tests {
fn global_trim_left_table() { fn global_trim_left_table() {
let row = Value::List { let row = Value::List {
vals: vec![ vals: vec![
Value::string(" a ", Span::test_data()), Value::test_string(" a "),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string(" d", Span::test_data()), Value::test_string(" d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
let expected = Value::List { let expected = Value::List {
vals: vec![ vals: vec![
Value::string("a ", Span::test_data()), Value::test_string("a "),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string("d", Span::test_data()), Value::test_string("d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
@ -783,17 +783,17 @@ mod tests {
fn global_trim_right_table() { fn global_trim_right_table() {
let row = Value::List { let row = Value::List {
vals: vec![ vals: vec![
Value::string(" a ", Span::test_data()), Value::test_string(" a "),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string(" d", Span::test_data()), Value::test_string(" d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
let expected = Value::List { let expected = Value::List {
vals: vec![ vals: vec![
Value::string(" a", Span::test_data()), Value::test_string(" a"),
Value::int(65, Span::test_data()), Value::int(65, Span::test_data()),
Value::string(" d", Span::test_data()), Value::test_string(" d"),
], ],
span: Span::test_data(), span: Span::test_data(),
}; };
@ -910,17 +910,17 @@ mod tests {
fn global_trim_format_flag_table() { fn global_trim_format_flag_table() {
let row = Value::List { let row = Value::List {
vals: vec![ 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::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(), span: Span::test_data(),
}; };
let expected = Value::List { let expected = Value::List {
vals: vec![ 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::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(), span: Span::test_data(),
}; };

View File

@ -140,27 +140,27 @@ prints out the list properly."#
Example { Example {
description: "Render a simple list to a grid", description: "Render a simple list to a grid",
example: "[1 2 3 a b c] | 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 { Example {
description: "The above example is the same as:", description: "The above example is the same as:",
example: "[1 2 3 a b c] | wrap name | grid", 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 { Example {
description: "Render a record to a grid", description: "Render a record to a grid",
example: "{name: 'foo', b: 1, c: 2} | 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 { Example {
description: "Render a list of records to a grid", description: "Render a list of records to a grid",
example: "[{name: 'A', v: 1} {name: 'B', v: 2} {name: 'C', v: 3}] | 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 { Example {
description: "Render a table with 'name' column in it to a grid", 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", 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")),
}, },
] ]
} }

View File

@ -356,17 +356,17 @@ fn handle_table_command(
fn supported_table_modes() -> Vec<Value> { fn supported_table_modes() -> Vec<Value> {
vec![ vec![
Value::string("basic", Span::test_data()), Value::test_string("basic"),
Value::string("compact", Span::test_data()), Value::test_string("compact"),
Value::string("compact_double", Span::test_data()), Value::test_string("compact_double"),
Value::string("default", Span::test_data()), Value::test_string("default"),
Value::string("heavy", Span::test_data()), Value::test_string("heavy"),
Value::string("light", Span::test_data()), Value::test_string("light"),
Value::string("none", Span::test_data()), Value::test_string("none"),
Value::string("reinforced", Span::test_data()), Value::test_string("reinforced"),
Value::string("rounded", Span::test_data()), Value::test_string("rounded"),
Value::string("thin", Span::test_data()), Value::test_string("thin"),
Value::string("with_love", Span::test_data()), Value::test_string("with_love"),
] ]
} }

View File

@ -4,7 +4,7 @@ use nu_protocol::{Span, Value};
fn test_comparison_nothing() { fn test_comparison_nothing() {
let values = vec![ let values = vec![
Value::int(1, Span::test_data()), Value::int(1, Span::test_data()),
Value::string("string", Span::test_data()), Value::test_string("string"),
Value::float(1.0, Span::test_data()), Value::float(1.0, Span::test_data()),
]; ];

View File

@ -120,7 +120,7 @@ mod tests {
#[test] #[test]
fn major() { 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(); let mut inc = Inc::new();
inc.for_semver(SemVerAction::Major); inc.for_semver(SemVerAction::Major);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected) assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)
@ -128,7 +128,7 @@ mod tests {
#[test] #[test]
fn minor() { 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(); let mut inc = Inc::new();
inc.for_semver(SemVerAction::Minor); inc.for_semver(SemVerAction::Minor);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected) assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)
@ -136,7 +136,7 @@ mod tests {
#[test] #[test]
fn patch() { 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(); let mut inc = Inc::new();
inc.for_semver(SemVerAction::Patch); inc.for_semver(SemVerAction::Patch);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected) assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)