Change other instances of $nothing to null (#7569)

# Description

Purely for consistency, various remaining instances of `$nothing`
(almost all of which were in test code) have been changed to `null`.
Now, the only place that refers to `$nothing` is the parser code which
implements it.

# User-Facing Changes

The default config.nu now uses `null` in certain places where it used
`$nothing`.

# 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

# 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:
Leon
2022-12-23 06:30:10 +10:00
committed by GitHub
parent 9d1cb1bfaf
commit 8e1112c1dd
9 changed files with 30 additions and 30 deletions

View File

@ -114,7 +114,7 @@ fn def_with_no_dollar() -> TestResult {
#[test]
fn allow_missing_optional_params() -> TestResult {
run_test(
"def foo [x?:int] { if $x != $nothing { $x + 10 } else { 5 } }; foo",
"def foo [x?:int] { if $x != null { $x + 10 } else { 5 } }; foo",
"5",
)
}

View File

@ -75,7 +75,7 @@ fn earlier_errors() -> TestResult {
#[test]
fn missing_flags_are_nothing() -> TestResult {
run_test(
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == $nothing { 10 } else { $aaa }) + (if $bbb == $nothing { 100 } else { $bbb }) }; foo"#,
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == null { 10 } else { $aaa }) + (if $bbb == null { 100 } else { $bbb }) }; foo"#,
"110",
)
}
@ -83,7 +83,7 @@ fn missing_flags_are_nothing() -> TestResult {
#[test]
fn missing_flags_are_nothing2() -> TestResult {
run_test(
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == $nothing { 10 } else { $aaa }) + (if $bbb == $nothing { 100 } else { $bbb }) }; foo -a 90"#,
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == null { 10 } else { $aaa }) + (if $bbb == null { 100 } else { $bbb }) }; foo -a 90"#,
"190",
)
}
@ -91,7 +91,7 @@ fn missing_flags_are_nothing2() -> TestResult {
#[test]
fn missing_flags_are_nothing3() -> TestResult {
run_test(
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == $nothing { 10 } else { $aaa }) + (if $bbb == $nothing { 100 } else { $bbb }) }; foo -b 45"#,
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == null { 10 } else { $aaa }) + (if $bbb == null { 100 } else { $bbb }) }; foo -b 45"#,
"55",
)
}
@ -99,7 +99,7 @@ fn missing_flags_are_nothing3() -> TestResult {
#[test]
fn missing_flags_are_nothing4() -> TestResult {
run_test(
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == $nothing { 10 } else { $aaa }) + (if $bbb == $nothing { 100 } else { $bbb }) }; foo -a 3 -b 10000"#,
r#"def foo [--aaa(-a): int, --bbb(-b): int] { (if $aaa == null { 10 } else { $aaa }) + (if $bbb == null { 100 } else { $bbb }) }; foo -a 3 -b 10000"#,
"10003",
)
}

View File

@ -173,9 +173,9 @@ fn update_cell_path_1() -> TestResult {
#[test]
fn missing_column_fills_in_nothing() -> TestResult {
// The empty value will be replaced with $nothing when fetching a column
// The empty value will be replaced with null when fetching a column
run_test(
r#"[ { name: ABC, size: 20 }, { name: HIJ } ].size.1 == $nothing"#,
r#"[ { name: ABC, size: 20 }, { name: HIJ } ].size.1 == null"#,
"true",
)
}
@ -258,7 +258,7 @@ fn length_defaulted_columns() -> TestResult {
#[test]
fn get_fuzzy() -> TestResult {
run_test("(ls | get -i foo) == $nothing", "true")
run_test("(ls | get -i foo) == null", "true")
}
#[test]