forked from extern/nushell
Require that values that look like numbers parse as numberlike (#8635)
# Description Require that any value that looks like it might be a number (starts with a digit, or a '-' + digit, or a '+' + digits, or a special form float like `-inf`, `inf`, or `NaN`) must now be treated as a number-like value. Number-like syntax can only parse into number-like values. Number-like values include: durations, ints, floats, ranges, filesizes, binary data, etc. # User-Facing Changes BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE BREAKING CHANGE Just making sure we see this for release notes 😅 This breaks any and all numberlike values that were treated as strings before. Example, we used to allow `3,` as a bare word. Anything like this would now require quotes or backticks to be treated as a string or bare word, respectively. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -44,10 +44,10 @@ fn checks_all_columns_of_a_table_is_true() {
|
||||
r#"
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
[ JT, Turner, 10/12/2013, 1 ]
|
||||
[ Darren, Schroeder, 10/11/2013, 1 ]
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
[ Andrés, Robalino, '10/11/2013', 1 ]
|
||||
[ JT, Turner, '10/12/2013', 1 ]
|
||||
[ Darren, Schroeder, '10/11/2013', 1 ]
|
||||
[ Yehuda, Katz, '10/11/2013', 1 ]
|
||||
]
|
||||
| all {|x| $x.likes > 0 }
|
||||
"#
|
||||
|
@ -20,12 +20,12 @@ fn checks_any_column_of_a_table_is_true() {
|
||||
r#"
|
||||
echo [
|
||||
[ first_name, last_name, rusty_at, likes ];
|
||||
[ Andrés, Robalino, 10/11/2013, 1 ]
|
||||
[ JT, Turner, 10/12/2013, 1 ]
|
||||
[ Darren, Schroeder, 10/11/2013, 1 ]
|
||||
[ Yehuda, Katz, 10/11/2013, 1 ]
|
||||
[ Andrés, Robalino, '10/11/2013', 1 ]
|
||||
[ JT, Turner, '10/12/2013', 1 ]
|
||||
[ Darren, Schroeder, '10/11/2013', 1 ]
|
||||
[ Yehuda, Katz, '10/11/2013', 1 ]
|
||||
]
|
||||
| any {|x| $x.rusty_at == 10/12/2013 }
|
||||
| any {|x| $x.rusty_at == '10/12/2013' }
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -33,7 +33,7 @@ fn cal_friday_the_thirteenths_in_2015() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
cal --full-year 2015 | default friday 0 | where friday == 13 | length
|
||||
cal --full-year 2015 | default 0 friday | where friday == 13 | length
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -367,7 +367,7 @@ fn does_not_error_when_some_file_is_moving_into_itself() {
|
||||
|
||||
let original_dir = dirs.test().join("11");
|
||||
let expected = dirs.test().join("12/11");
|
||||
nu!(cwd: dirs.test(), "mv 1* 12");
|
||||
nu!(cwd: dirs.test(), "mv `1*` `12`");
|
||||
|
||||
assert!(!original_dir.exists());
|
||||
assert!(expected.exists());
|
||||
|
@ -7,9 +7,9 @@ fn regular_columns() {
|
||||
echo [
|
||||
[first_name, last_name, rusty_at, type];
|
||||
|
||||
[Andrés Robalino 10/11/2013 A]
|
||||
[JT Turner 10/12/2013 B]
|
||||
[Yehuda Katz 10/11/2013 A]
|
||||
[Andrés Robalino '10/11/2013' A]
|
||||
[JT Turner '10/12/2013' B]
|
||||
[Yehuda Katz '10/11/2013' A]
|
||||
]
|
||||
| reject type first_name
|
||||
| columns
|
||||
|
@ -219,7 +219,7 @@ fn external_command_expand_tilde_with_back_quotes() {
|
||||
"external command not expand tilde with quotes",
|
||||
|dirs, _| {
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(r#"nu --testbin nonu `~`"#));
|
||||
assert!(!actual.out.contains("~"));
|
||||
assert!(!actual.out.contains('~'));
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ fn regular_columns() {
|
||||
echo [
|
||||
[first_name, last_name, rusty_at, type];
|
||||
|
||||
[Andrés Robalino 10/11/2013 A]
|
||||
[JT Turner 10/12/2013 B]
|
||||
[Yehuda Katz 10/11/2013 A]
|
||||
[Andrés Robalino '10/11/2013' A]
|
||||
[JT Turner '10/12/2013' B]
|
||||
[Yehuda Katz '10/11/2013' A]
|
||||
]
|
||||
| select rusty_at last_name
|
||||
| get 0
|
||||
@ -72,9 +72,9 @@ fn fails_if_given_unknown_column_name() {
|
||||
echo [
|
||||
[first_name, last_name, rusty_at, type];
|
||||
|
||||
[Andrés Robalino 10/11/2013 A]
|
||||
[JT Turner 10/12/2013 B]
|
||||
[Yehuda Katz 10/11/2013 A]
|
||||
[Andrés Robalino '10/11/2013' A]
|
||||
[JT Turner '10/12/2013' B]
|
||||
[Yehuda Katz '10/11/2013' A]
|
||||
]
|
||||
| select rrusty_at first_name
|
||||
| length
|
||||
|
@ -234,7 +234,7 @@ fn substrings_the_input() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring 6,14 fortune.teller.phone
|
||||
| str substring '6,14' fortune.teller.phone
|
||||
| get fortune.teller.phone
|
||||
"#
|
||||
));
|
||||
@ -258,7 +258,7 @@ fn substring_errors_if_start_index_is_greater_than_end_index() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring 6,5 fortune.teller.phone
|
||||
| str substring '6,5' fortune.teller.phone
|
||||
"#
|
||||
));
|
||||
|
||||
@ -283,7 +283,7 @@ fn substrings_the_input_and_returns_the_string_if_end_index_exceeds_length() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring 0,999 package.name
|
||||
| str substring '0,999' package.name
|
||||
| get package.name
|
||||
"#
|
||||
));
|
||||
@ -307,7 +307,7 @@ fn substrings_the_input_and_returns_blank_if_start_index_exceeds_length() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring 50,999 package.name
|
||||
| str substring '50,999' package.name
|
||||
| get package.name
|
||||
"#
|
||||
));
|
||||
@ -331,7 +331,7 @@ fn substrings_the_input_and_treats_start_index_as_zero_if_blank_start_index_give
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring ,2 package.name
|
||||
| str substring ',2' package.name
|
||||
| get package.name
|
||||
"#
|
||||
));
|
||||
@ -355,7 +355,7 @@ fn substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open sample.toml
|
||||
| str substring 3, package.name
|
||||
| str substring '3,' package.name
|
||||
| get package.name
|
||||
"#
|
||||
));
|
||||
|
Reference in New Issue
Block a user