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
50 changed files with 191 additions and 235 deletions

View File

@ -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,

View File

@ -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",

View File

@ -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",

View File

@ -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(),
}),

View File

@ -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(),
}),

View File

@ -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(),

View File

@ -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(),
}),

View File

@ -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(),
}),

View File

@ -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(),
}),

View File

@ -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(),
}),

View File

@ -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(),
}),

View File

@ -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")),
},
]
}

View File

@ -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")),
},
]
}

View File

@ -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("▉▉▉▉▉▉▉▉▉▉")),
},
]
}

View File

@ -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"));
}
}

View File

@ -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(),
}),

View File

@ -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("▉▉▉▉▉▉▉▉▉▉")),
},
]
}

View File

@ -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)),

View File

@ -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(),
};