reject multiple row args support (#10163)

# Description
This PR fixes `reject` failing when providing row items in ascending
order.


# User-Facing Changes
users can now `reject` multiple rows independently of each other.
```nushell
let foo = [[a b]; [ 1 2] [3 4] [ 5 6]]
# this will work independant of the order
print ($foo | reject 2 1)
print ($foo | reject 1 2)
```

---------

Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
This commit is contained in:
Tilen Gimpelj
2023-09-09 20:59:31 +02:00
committed by GitHub
parent 17abbdf6e0
commit 248aca7a44
2 changed files with 70 additions and 7 deletions

View File

@@ -79,6 +79,12 @@ fn ignores_duplicate_columns_rejected() {
assert_eq!(actual.out, "last name");
}
#[test]
fn ignores_duplicate_rows_rejected() {
let actual = nu!("[[a,b];[1 2] [3 4] [5 6]] | reject 2 2 | to nuon");
assert_eq!(actual.out, "[[a, b]; [1, 2], [3, 4]]");
}
#[test]
fn reject_record_from_raw_eval() {
let actual = nu!(r#"{"a": 3} | reject a | describe"#);
@@ -143,3 +149,15 @@ fn reject_optional_row() {
let actual = nu!("[{foo: 'bar'}] | reject 3? | to nuon");
assert_eq!(actual.out, "[[foo]; [bar]]");
}
#[test]
fn reject_multiple_rows_ascending() {
let actual = nu!("[[a,b];[1 2] [3 4] [5 6]] | reject 1 2 | to nuon");
assert_eq!(actual.out, "[[a, b]; [1, 2]]");
}
#[test]
fn reject_multiple_rows_descending() {
let actual = nu!("[[a,b];[1 2] [3 4] [5 6]] | reject 2 1 | to nuon");
assert_eq!(actual.out, "[[a, b]; [1, 2]]");
}