mirror of
https://github.com/nushell/nushell.git
synced 2025-01-25 15:51:28 +01:00
add $nothing and tests (#2995)
This commit is contained in:
parent
2c52144f41
commit
fd41fa31d5
@ -253,6 +253,11 @@ fn evaluate_reference(name: &str, ctx: &EvaluationContext, tag: Tag) -> Result<V
|
|||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"$nothing" => Ok(Value {
|
||||||
|
value: UntaggedValue::nothing(),
|
||||||
|
tag,
|
||||||
|
}),
|
||||||
|
|
||||||
x => match ctx.scope.get_var(x) {
|
x => match ctx.scope.get_var(x) {
|
||||||
Some(v) => Ok(v),
|
Some(v) => Ok(v),
|
||||||
None => Err(ShellError::labeled_error(
|
None => Err(ShellError::labeled_error(
|
||||||
|
@ -11,3 +11,26 @@ fn test_parse_invocation_with_range() {
|
|||||||
);
|
);
|
||||||
assert_eq!(actual.out, "[1,2,3]")
|
assert_eq!(actual.out, "[1,2,3]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn create_nothing_in_table() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
echo [[column]; [$nothing]] | to json
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
assert_eq!(actual.out, "{\"column\":null}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn compare_to_nothing() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
let f = $nothing
|
||||||
|
if $f == $nothing {echo $true} {echo $false}
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
assert_eq!(actual.out, "true");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user