mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 05:58:13 +02:00
Add modulo operator and simplify in/not-in (#2505)
This commit is contained in:
@ -161,6 +161,18 @@ fn parens_precedence() {
|
||||
assert_eq!(actual.out, "12");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modulo() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
= 9 mod 2
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duration_math() {
|
||||
let actual = nu!(
|
||||
|
@ -31,7 +31,7 @@ fn row() {
|
||||
r#"
|
||||
open caballeros.csv
|
||||
| merge { open new_caballeros.csv }
|
||||
| where country in: ["Guayaquil Ecuador" "New Zealand"]
|
||||
| where country in ["Guayaquil Ecuador" "New Zealand"]
|
||||
| get luck
|
||||
| math sum
|
||||
| echo $it
|
||||
|
@ -27,7 +27,7 @@ fn filters_with_nothing_comparison() {
|
||||
fn where_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in: ["foo"] | get size | math sum | echo $it"#
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
@ -37,7 +37,7 @@ fn where_in_table() {
|
||||
fn where_not_in_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in: ["foo"] | get size | math sum | echo $it"#
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
|
Reference in New Issue
Block a user