RangeIterator can also go down (#2913)

This commit is contained in:
Chris Gillespie
2021-01-12 11:27:54 -08:00
committed by GitHub
parent 3be198d2f5
commit dff85a7f70
2 changed files with 88 additions and 3 deletions

View File

@ -11,3 +11,51 @@ fn echo_range_is_lazy() {
assert_eq!(actual.out, "[1,2,3]");
}
#[test]
fn echo_range_handles_inclusive() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo 1..3 | to json
"#
));
assert_eq!(actual.out, "[1,2,3]");
}
#[test]
fn echo_range_handles_exclusive() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo 1..<3 | to json
"#
));
assert_eq!(actual.out, "[1,2]");
}
#[test]
fn echo_range_handles_inclusive_down() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo 3..1 | to json
"#
));
assert_eq!(actual.out, "[3,2,1]");
}
#[test]
fn echo_range_handles_exclusive_down() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo 3..<1 | to json
"#
));
assert_eq!(actual.out, "[3,2]");
}