preserve space by letting to nuon only add quotes when necessary (#6379)

* preserve space by letting `to nuon` only add quotes when necessary

* fix CI, add quotes with colon

* fmt

* add more chars to blacklist
This commit is contained in:
pwygab
2022-08-23 19:51:07 +08:00
committed by GitHub
parent d97975e9fa
commit 884382bac4
2 changed files with 63 additions and 4 deletions

View File

@ -249,3 +249,21 @@ fn to_nuon_converts_columns_with_spaces() {
));
assert!(actual.err.is_empty());
}
#[test]
fn to_nuon_does_not_quote_unnecessarily() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
let test = [["a", "b", "c d"]; [1 2 3] [4 5 6]]; $test | to nuon
"#
));
assert_eq!(actual.out, "[[a, b, \"c d\"]; [1, 2, 3], [4, 5, 6]]");
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
let a = {"ro name": "sam" rank: 10}; $a | to nuon
"#
));
assert_eq!(actual.out, "{\"ro name\": sam, rank: 10}");
}