diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/non262/JSON/parse-with-source.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/JSON/parse-with-source.js')
-rw-r--r-- | js/src/tests/non262/JSON/parse-with-source.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/tests/non262/JSON/parse-with-source.js b/js/src/tests/non262/JSON/parse-with-source.js new file mode 100644 index 0000000000..96e9550706 --- /dev/null +++ b/js/src/tests/non262/JSON/parse-with-source.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('json-parse-with-source'))) shell-option(--enable-json-parse-with-source) + +var actual; + +function reviver(key, value, context) { + assertEq(arguments.length, 3); + assertEq("source" in context, true); + actual = context["source"]; +} + +let tests = [ + // STRINGS + {input: '""', expected: '""'}, + {input: '"str"', expected: '"str"'}, + {input: '"str" ', expected: '"str"'}, + {input: ' "str" ', expected: '"str"'}, + {input: ' " str"', expected: '" str"'}, + {input: '"\uD83D\uDE0A\u2764\u2FC1"', expected: '"\uD83D\uDE0A\u2764\u2FC1"'}, + // NUMBERS + {input: '1', expected: '1'}, + {input: ' 1', expected: '1'}, + {input: '4.2', expected: '4.2'}, + {input: '4.2 ', expected: '4.2'}, + {input: '4.2000 ', expected: '4.2000'}, + {input: '4e2000 ', expected: '4e2000'}, + {input: '4.4e2000 ', expected: '4.4e2000'}, + {input: '9007199254740999', expected: '9007199254740999'}, + {input: '-31', expected: '-31'}, + {input: '-3.1', expected: '-3.1'}, + {input: ' -31 ', expected: '-31'}, + // BOOLEANS + {input: 'true', expected: 'true'}, + {input: 'true ', expected: 'true'}, + {input: 'false', expected: 'false'}, + {input: ' false', expected: 'false'}, + // NULL + {input: 'null', expected: 'null'}, + {input: ' null', expected: 'null'}, + {input: '\tnull ', expected: 'null'}, + {input: 'null\t', expected: 'null'}, +]; +for (const test of tests) { + print("Testing " + JSON.stringify(test)); + JSON.parse(test.input, reviver); + assertEq(actual, test.expected); +} + +if (typeof reportCompare == 'function') + reportCompare(0, 0);
\ No newline at end of file |