fix multiline strings in NDNUON (#14519)

- should close https://github.com/nushell/nushell/issues/14517

# Description
this will change `to ndnuon` so that newlines are encoded as a literal
`\n` which `from ndnuon` is already able to handle

# User-Facing Changes
users should be able to encode multiline strings in NDNUON

# Tests + Formatting
new tests have been added:
- they don't pass on the first commit
- they do pass with the fix

# After Submitting
This commit is contained in:
Antoine Stevan
2024-12-05 14:53:33 +01:00
committed by GitHub
parent 234484b6f8
commit d97562f6e8
3 changed files with 29 additions and 1 deletions

View File

@ -128,3 +128,17 @@ def to_ndnuon_single_object [] {
let expect = "{a: 1}"
assert equal $result $expect "could not convert to NDNUON"
}
#[test]
def to_ndnuon_multiline_strings [] {
let result = "foo\n\\n\nbar" | to ndnuon
let expect = '"foo\n\\n\nbar"'
assert equal $result $expect "could not convert multiline string to NDNUON"
}
#[test]
def from_ndnuon_multiline_strings [] {
let result = '"foo\n\\n\nbar"' | from ndnuon
let expect = ["foo\n\\n\nbar"]
assert equal $result $expect "could not convert multiline string from NDNUON"
}

View File

@ -128,3 +128,17 @@ def to_ndnuon_single_object [] {
let expect = "{a: 1}"
assert equal $result $expect "could not convert to NDNUON"
}
#[test]
def to_ndnuon_multiline_strings [] {
let result = "foo\n\\n\nbar" | formats to ndnuon
let expect = '"foo\n\\n\nbar"'
assert equal $result $expect "could not convert multiline string to NDNUON"
}
#[test]
def from_ndnuon_multiline_strings [] {
let result = '"foo\n\\n\nbar"' | formats from ndnuon
let expect = ["foo\n\\n\nbar"]
assert equal $result $expect "could not convert multiline string from NDNUON"
}