forked from extern/nushell
Remove interpretation of Primitive::Nothing
as the number 0. (#1836)
This commit is contained in:
parent
0743b69ad5
commit
6efabef8d3
@ -153,13 +153,7 @@ fn coerce_compare_primitive(
|
|||||||
(Bytes(left), Decimal(right)) => {
|
(Bytes(left), Decimal(right)) => {
|
||||||
CompareValues::Decimals(BigDecimal::from(*left), right.clone())
|
CompareValues::Decimals(BigDecimal::from(*left), right.clone())
|
||||||
}
|
}
|
||||||
(Bytes(left), Nothing) => CompareValues::Ints(BigInt::from(*left), BigInt::from(0)),
|
(Nothing, Nothing) => CompareValues::Booleans(true, true),
|
||||||
(Nothing, Nothing) => CompareValues::Ints(BigInt::from(0), BigInt::from(0)),
|
|
||||||
(Nothing, Bytes(right)) => CompareValues::Ints(BigInt::from(0), BigInt::from(*right)),
|
|
||||||
(Int(left), Nothing) => CompareValues::Ints(left.clone(), BigInt::from(0)),
|
|
||||||
(Nothing, Int(right)) => CompareValues::Ints(BigInt::from(0), right.clone()),
|
|
||||||
(Decimal(left), Nothing) => CompareValues::Decimals(left.clone(), BigDecimal::from(0.0)),
|
|
||||||
(Nothing, Decimal(right)) => CompareValues::Decimals(BigDecimal::from(0.0), right.clone()),
|
|
||||||
(String(left), String(right)) => CompareValues::String(left.clone(), right.clone()),
|
(String(left), String(right)) => CompareValues::String(left.clone(), right.clone()),
|
||||||
(Line(left), String(right)) => CompareValues::String(left.clone(), right.clone()),
|
(Line(left), String(right)) => CompareValues::String(left.clone(), right.clone()),
|
||||||
(String(left), Line(right)) => CompareValues::String(left.clone(), right.clone()),
|
(String(left), Line(right)) => CompareValues::String(left.clone(), right.clone()),
|
||||||
|
@ -26,10 +26,6 @@ impl ExtractType for bool {
|
|||||||
value: UntaggedValue::Primitive(Primitive::Boolean(b)),
|
value: UntaggedValue::Primitive(Primitive::Boolean(b)),
|
||||||
..
|
..
|
||||||
} => Ok(*b),
|
} => Ok(*b),
|
||||||
Value {
|
|
||||||
value: UntaggedValue::Primitive(Primitive::Nothing),
|
|
||||||
..
|
|
||||||
} => Ok(false),
|
|
||||||
other => Err(ShellError::type_error("Boolean", other.spanned_type_name())),
|
other => Err(ShellError::type_error("Boolean", other.spanned_type_name())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ fn cal_friday_the_thirteenths_in_2015() {
|
|||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: ".", pipeline(
|
cwd: ".", pipeline(
|
||||||
r#"
|
r#"
|
||||||
cal --full-year 2015 | where friday == 13 | count
|
cal --full-year 2015 | get friday | compact | where $it == 13 | count
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ fn filters_by_unit_size_comparison() {
|
|||||||
fn filters_with_nothing_comparison() {
|
fn filters_with_nothing_comparison() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats",
|
cwd: "tests/fixtures/formats",
|
||||||
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | where foo > 1 | get foo | sum | echo $it"#
|
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | sum | echo $it"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "7");
|
assert_eq!(actual.out, "7");
|
||||||
|
@ -105,7 +105,6 @@ impl num_traits::Zero for Primitive {
|
|||||||
Primitive::Int(int) => int.is_zero(),
|
Primitive::Int(int) => int.is_zero(),
|
||||||
Primitive::Decimal(decimal) => decimal.is_zero(),
|
Primitive::Decimal(decimal) => decimal.is_zero(),
|
||||||
Primitive::Bytes(size) => size.is_zero(),
|
Primitive::Bytes(size) => size.is_zero(),
|
||||||
Primitive::Nothing => true,
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ macro_rules! nu {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mut paths = $crate::shell_os_paths();
|
let mut paths = $crate::shell_os_paths();
|
||||||
paths.push(test_bins);
|
paths.insert(0, test_bins);
|
||||||
|
|
||||||
let paths_joined = match std::env::join_paths(paths.iter()) {
|
let paths_joined = match std::env::join_paths(paths.iter()) {
|
||||||
Ok(all) => all,
|
Ok(all) => all,
|
||||||
|
@ -17,7 +17,6 @@ impl Average {
|
|||||||
|
|
||||||
pub fn average(&mut self, value: Value) -> Result<(), ShellError> {
|
pub fn average(&mut self, value: Value) -> Result<(), ShellError> {
|
||||||
match &value.value {
|
match &value.value {
|
||||||
UntaggedValue::Primitive(Primitive::Nothing) => Ok(()),
|
|
||||||
UntaggedValue::Primitive(Primitive::Int(i)) => match &self.total {
|
UntaggedValue::Primitive(Primitive::Int(i)) => match &self.total {
|
||||||
Some(Value {
|
Some(Value {
|
||||||
value: UntaggedValue::Primitive(Primitive::Int(j)),
|
value: UntaggedValue::Primitive(Primitive::Int(j)),
|
||||||
|
@ -25,6 +25,7 @@ fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
|
|||||||
| get name
|
| get name
|
||||||
| ^echo $it
|
| ^echo $it
|
||||||
| nu --testbin chop
|
| nu --testbin chop
|
||||||
|
| lines
|
||||||
| nth 3
|
| nth 3
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
@ -89,8 +90,7 @@ fn invocation_handles_dot() {
|
|||||||
r#"
|
r#"
|
||||||
echo $(open nu_times.csv)
|
echo $(open nu_times.csv)
|
||||||
| get name
|
| get name
|
||||||
| ^echo $it
|
| nu --testbin chop $it
|
||||||
| nu --testbin chop
|
|
||||||
| nth 3
|
| nth 3
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
|
Loading…
Reference in New Issue
Block a user