mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 08:48:51 +02:00
fix nuon conversions of range values (#14687)
# Description Currently the step size of range values are discarded when converting to nuon. This PR fixes that and makes `to nuon | from nuon` round trips work. # User-Facing Changes `to nuon` conversion of `range` values now include the step size # Tests + Formatting Added some additional tests to cover inclusive/exclusive integer/float and step size cases.
This commit is contained in:
@ -179,27 +179,56 @@ fn to_nuon_records() {
|
||||
|
||||
#[test]
|
||||
fn to_nuon_range() {
|
||||
let actual = nu!(pipeline(
|
||||
r#"
|
||||
1..42
|
||||
| to nuon
|
||||
"#
|
||||
));
|
||||
|
||||
let actual = nu!(r#"1..42 | to nuon"#);
|
||||
assert_eq!(actual.out, "1..42");
|
||||
|
||||
let actual = nu!(r#"1..<42 | to nuon"#);
|
||||
assert_eq!(actual.out, "1..<42");
|
||||
|
||||
let actual = nu!(r#"1..4..42 | to nuon"#);
|
||||
assert_eq!(actual.out, "1..4..42");
|
||||
|
||||
let actual = nu!(r#"1..4..<42 | to nuon"#);
|
||||
assert_eq!(actual.out, "1..4..<42");
|
||||
|
||||
let actual = nu!(r#"1.0..42.0 | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..42.0");
|
||||
|
||||
let actual = nu!(r#"1.0..<42.0 | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..<42.0");
|
||||
|
||||
let actual = nu!(r#"1.0..4.0..42.0 | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..4.0..42.0");
|
||||
|
||||
let actual = nu!(r#"1.0..4.0..<42.0 | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..4.0..<42.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_nuon_range() {
|
||||
let actual = nu!(pipeline(
|
||||
r#"
|
||||
"1..42"
|
||||
| from nuon
|
||||
| describe
|
||||
"#
|
||||
));
|
||||
let actual = nu!(r#"'1..42' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1..42");
|
||||
|
||||
assert_eq!(actual.out, "range");
|
||||
let actual = nu!(r#"'1..<42' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1..<42");
|
||||
|
||||
let actual = nu!(r#"'1..4..42' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1..4..42");
|
||||
|
||||
let actual = nu!(r#"'1..4..<42' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1..4..<42");
|
||||
|
||||
let actual = nu!(r#"'1.0..42.0' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..42.0");
|
||||
|
||||
let actual = nu!(r#"'1.0..<42.0' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..<42.0");
|
||||
|
||||
let actual = nu!(r#"'1.0..4.0..42.0' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..4.0..42.0");
|
||||
|
||||
let actual = nu!(r#"'1.0..4.0..<42.0' | from nuon | to nuon"#);
|
||||
assert_eq!(actual.out, "1.0..4.0..<42.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user