JSON: More JSON5 data tests (#10453)

This commit is contained in:
fisker Cheung authored and GitHub committed 2021-03-02 13:43:48 +08:00
1 parent 2edfec5eda
commit 2f384ab24a
3 files changed
+325 -167

No files matched your search

+300 -156
View File
@@ -205,6 +205,306 @@ true
================================================================================
`;
exports[`json5.json - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["json"]
printWidth: 80
trailingComma: "all"
| printWidth
=====================================input======================================
[
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
}
]
=====================================output=====================================
[
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [Infinity, -Infinity, NaN],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
},
{
"//": "JSON5 numbers",
"hexadecimal": 0xdecaf,
"leadingDecimalPoint": 0.8675309,
"andTrailing": 8675309,
"positiveSign": +1
},
{
"//": "JSON5 strings",
"singleQuotes": "I can use \\"double quotes\\" here",
"lineBreaks": "Look, Mom! \\
No \\\\n's!"
}
]
================================================================================
`;
exports[`json5.json - {"trailingComma":"all"} format 2`] = `
====================================options=====================================
parsers: ["json5"]
printWidth: 80
trailingComma: "all"
| printWidth
=====================================input======================================
[
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
}
]
=====================================output=====================================
[
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
numbers: [Infinity, -Infinity, NaN],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
"//": "JSON5 numbers",
hexadecimal: 0xdecaf,
leadingDecimalPoint: 0.8675309,
andTrailing: 8675309,
positiveSign: +1,
},
{
"//": "JSON5 strings",
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
},
]
================================================================================
`;
exports[`json5.json format 1`] = `
====================================options=====================================
parsers: ["json"]
printWidth: 80
| printWidth
=====================================input======================================
[
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
}
]
=====================================output=====================================
[
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [Infinity, -Infinity, NaN],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
},
{
"//": "JSON5 numbers",
"hexadecimal": 0xdecaf,
"leadingDecimalPoint": 0.8675309,
"andTrailing": 8675309,
"positiveSign": +1
},
{
"//": "JSON5 strings",
"singleQuotes": "I can use \\"double quotes\\" here",
"lineBreaks": "Look, Mom! \\
No \\\\n's!"
}
]
================================================================================
`;
exports[`json5.json format 2`] = `
====================================options=====================================
parsers: ["json5"]
printWidth: 80
| printWidth
=====================================input======================================
[
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
}
]
=====================================output=====================================
[
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
numbers: [Infinity, -Infinity, NaN],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
"//": "JSON5 numbers",
hexadecimal: 0xdecaf,
leadingDecimalPoint: 0.8675309,
andTrailing: 8675309,
positiveSign: +1,
},
{
"//": "JSON5 strings",
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
},
]
================================================================================
`;
exports[`json5.json format 3`] = `
====================================options=====================================
parsers: ["json-stringify"]
printWidth: 80
| printWidth
=====================================input======================================
[
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \\
No \\\\n's!",
}
]
=====================================output=====================================
[
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [
Infinity,
-Infinity,
NaN
],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
},
{
"//": "JSON5 numbers",
"hexadecimal": 912559,
"leadingDecimalPoint": 0.8675309,
"andTrailing": 8675309,
"positiveSign": 1
},
{
"//": "JSON5 strings",
"singleQuotes": "I can use \\"double quotes\\" here",
"lineBreaks": "Look, Mom! No \\\\n's!"
}
]
================================================================================
`;
exports[`key-value.json - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["json"]
@@ -553,162 +853,6 @@ printWidth: 80
================================================================================
`;
exports[`numbers.json - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["json"]
printWidth: 80
trailingComma: "all"
| printWidth
=====================================input======================================
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
=====================================output=====================================
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [Infinity, -Infinity, NaN],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
}
================================================================================
`;
exports[`numbers.json - {"trailingComma":"all"} format 2`] = `
====================================options=====================================
parsers: ["json5"]
printWidth: 80
trailingComma: "all"
| printWidth
=====================================input======================================
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
=====================================output=====================================
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
numbers: [Infinity, -Infinity, NaN],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
================================================================================
`;
exports[`numbers.json format 1`] = `
====================================options=====================================
parsers: ["json"]
printWidth: 80
| printWidth
=====================================input======================================
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
=====================================output=====================================
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [Infinity, -Infinity, NaN],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
}
================================================================================
`;
exports[`numbers.json format 2`] = `
====================================options=====================================
parsers: ["json5"]
printWidth: 80
| printWidth
=====================================input======================================
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
=====================================output=====================================
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
numbers: [Infinity, -Infinity, NaN],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
================================================================================
`;
exports[`numbers.json format 3`] = `
====================================options=====================================
parsers: ["json-stringify"]
printWidth: 80
| printWidth
=====================================input======================================
{
'//': 'JSON5 allow \`Infinity\` and \`NaN\`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}
=====================================output=====================================
{
"//": "JSON5 allow \`Infinity\` and \`NaN\`",
"numbers": [
Infinity,
-Infinity,
NaN
],
"Infinity": NaN,
"NaN": Infinity,
"NaN": -Infinity
}
================================================================================
`;
exports[`pass1.json - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["json"]
+25
View File
@@ -0,0 +1,25 @@
[
{
'//': 'JSON5 allow `Infinity` and `NaN`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
},
{
'//': 'JSON5 numbers',
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
},
{
'//': 'JSON5 strings',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
}
]
-11
View File
@@ -1,11 +0,0 @@
{
'//': 'JSON5 allow `Infinity` and `NaN`',
numbers: [
Infinity,
-Infinity,
NaN,
],
Infinity: NaN,
NaN: Infinity,
NaN: -Infinity,
}