Revert range expansion for to nuon (#8210)

# Description

The code to generate the nuon format supports writing range literals,
which obviates the need to expand the range as added in #8047

# User-Facing Changes

`to nuon` will still output ranges as literals

# Tests + Formatting

- Add test for `to nuon` range output
- Add `from nuon` test for range
This commit is contained in:
Stefan Holderbach 2023-02-25 18:29:30 +01:00 committed by GitHub
parent b36ac8f2f8
commit 836a56b347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -34,7 +34,6 @@ impl Command for ToNuon {
call: &Call, call: &Call,
input: PipelineData, input: PipelineData,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let input = input.try_expand_range()?;
Ok(Value::String { Ok(Value::String {
val: to_nuon(call, input)?, val: to_nuon(call, input)?,
span: call.head, span: call.head,

View File

@ -177,6 +177,33 @@ fn to_nuon_records() {
assert_eq!(actual.out, "true"); assert_eq!(actual.out, "true");
} }
#[test]
fn to_nuon_range() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
1..42
| to nuon
"#
));
assert_eq!(actual.out, "1..42");
}
#[test]
fn from_nuon_range() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
"1..42"
| from nuon
| describe
"#
));
assert_eq!(actual.out, "range");
}
#[test] #[test]
fn binary_to() { fn binary_to() {
let actual = nu!( let actual = nu!(