mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Improve range parsing and handling (#2506)
* Improve range parsing and handling * linting
This commit is contained in:
@ -454,6 +454,54 @@ fn list_with_commas() {
|
||||
assert_eq!(actual.out, "6");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn range_with_left_var() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
echo [[size]; [3]] | echo $it.size..10 | math sum
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "52");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn range_with_right_var() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
echo [[size]; [30]] | echo 4..$it.size | math sum
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "459");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn range_with_open_left() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
echo ..30 | math sum
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "465");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn range_with_open_right() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
echo 5.. | first 10 | math sum
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "95");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_expansion_of_tables() {
|
||||
let actual = nu!(
|
||||
|
Reference in New Issue
Block a user