Negative indexing for range (#3427)

* adds negative indexing to range

* fixes tests to reflect new parsing changes

* removes duplicate definitons

* fmt
This commit is contained in:
Alex Shadley
2021-05-16 22:08:47 -05:00
committed by GitHub
parent dc9cd7d8b9
commit 86e6fcd309
2 changed files with 79 additions and 6 deletions

View File

@ -43,3 +43,26 @@ fn selects_some_rows() {
assert_eq!(actual.out, "2");
});
}
#[test]
fn negative_indices() {
Playground::setup("range_test_negative_indices", |dirs, sandbox| {
sandbox.with_files(vec![
EmptyFile("notes.txt"),
EmptyFile("tests.txt"),
EmptyFile("persons.txt"),
]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls
| get name
| range (-1..)
| length
"#
));
assert_eq!(actual.out, "1");
});
}