mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 08:24:23 +02:00
Use standard test262 harness functions in non262-JSON-shell.js
This commit is contained in:
parent
57816febc2
commit
0633915e30
@ -1,114 +1,64 @@
|
|||||||
/*---
|
/*---
|
||||||
defines: [testJSON]
|
defines: [testJSON, testJSONSyntaxError]
|
||||||
allow_unused: True
|
allow_unused: True
|
||||||
---*/
|
---*/
|
||||||
function testJSON(str, expectSyntaxError)
|
|
||||||
{
|
function testJSON(str) {
|
||||||
// Leading and trailing whitespace never affect parsing, so test the string
|
// Leading and trailing whitespace never affect parsing, so test the string
|
||||||
// multiple times with and without whitespace around it as it's easy and can
|
// multiple times with and without whitespace around it as it's easy and can
|
||||||
// potentially detect bugs.
|
// potentially detect bugs.
|
||||||
|
|
||||||
// Try the provided string
|
// Try the provided string
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
JSON.parse(str);
|
JSON.parse(str);
|
||||||
reportCompare(false, expectSyntaxError,
|
} catch (e) {
|
||||||
"string <" + str + "> " +
|
throw new Test262Error("string <" + str + "> should have parsed as JSON");
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON");
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
if (!(e instanceof SyntaxError))
|
|
||||||
{
|
|
||||||
reportCompare(true, false,
|
|
||||||
"parsing string <" + str + "> threw a non-SyntaxError " +
|
|
||||||
"exception: " + e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reportCompare(true, expectSyntaxError,
|
|
||||||
"string <" + str + "> " +
|
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON, exception: " + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try the provided string with trailing whitespace
|
// Now try the provided string with trailing whitespace
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
JSON.parse(str + " ");
|
JSON.parse(str + " ");
|
||||||
reportCompare(false, expectSyntaxError,
|
} catch (e) {
|
||||||
"string <" + str + " > " +
|
throw new Test262Error("string <" + str + " > should have parsed as JSON");
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON");
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
if (!(e instanceof SyntaxError))
|
|
||||||
{
|
|
||||||
reportCompare(true, false,
|
|
||||||
"parsing string <" + str + " > threw a non-SyntaxError " +
|
|
||||||
"exception: " + e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reportCompare(true, expectSyntaxError,
|
|
||||||
"string <" + str + " > " +
|
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON, exception: " + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try the provided string with leading whitespace
|
// Now try the provided string with leading whitespace
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
JSON.parse(" " + str);
|
JSON.parse(" " + str);
|
||||||
reportCompare(false, expectSyntaxError,
|
} catch (e) {
|
||||||
"string < " + str + "> " +
|
throw new Test262Error("string < " + str + "> should have parsed as JSON");
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON");
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
if (!(e instanceof SyntaxError))
|
|
||||||
{
|
|
||||||
reportCompare(true, false,
|
|
||||||
"parsing string < " + str + "> threw a non-SyntaxError " +
|
|
||||||
"exception: " + e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reportCompare(true, expectSyntaxError,
|
|
||||||
"string < " + str + "> " +
|
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON, exception: " + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try the provided string with whitespace surrounding it
|
// Now try the provided string with whitespace surrounding it
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
JSON.parse(" " + str + " ");
|
JSON.parse(" " + str + " ");
|
||||||
reportCompare(false, expectSyntaxError,
|
} catch (e) {
|
||||||
"string < " + str + " > " +
|
throw new Test262Error("string < " + str + " > should have parsed as JSON");
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON");
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
if (!(e instanceof SyntaxError))
|
|
||||||
{
|
|
||||||
reportCompare(true, false,
|
|
||||||
"parsing string < " + str + " > threw a non-SyntaxError " +
|
|
||||||
"exception: " + e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reportCompare(true, expectSyntaxError,
|
|
||||||
"string < " + str + " > " +
|
|
||||||
"should" + (expectSyntaxError ? "n't" : "") + " " +
|
|
||||||
"have parsed as JSON, exception: " + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testJSONSyntaxError(str) {
|
||||||
|
// Leading and trailing whitespace never affect parsing, so test the string
|
||||||
|
// multiple times with and without whitespace around it as it's easy and can
|
||||||
|
// potentially detect bugs.
|
||||||
|
|
||||||
|
// Try the provided string
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
JSON.parse(str);
|
||||||
|
}, "string <" + str + "> shouldn't have parsed as JSON");
|
||||||
|
|
||||||
|
// Now try the provided string with trailing whitespace
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
JSON.parse(str + " ");
|
||||||
|
}, "string <" + str + " > shouldn't have parsed as JSON");
|
||||||
|
|
||||||
|
// Now try the provided string with leading whitespace
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
JSON.parse(" " + str);
|
||||||
|
}, "string < " + str + "> shouldn't have parsed as JSON");
|
||||||
|
|
||||||
|
// Now try the provided string with whitespace surrounding it
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
JSON.parse(" " + str + " ");
|
||||||
|
}, "string < " + str + " > shouldn't have parsed as JSON");
|
||||||
|
}
|
||||||
|
@ -4,36 +4,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
testJSON('-', true);
|
|
||||||
testJSON('+', true);
|
|
||||||
testJSON('-f', true);
|
|
||||||
testJSON('+f', true);
|
|
||||||
testJSON('00', true);
|
|
||||||
testJSON('01', true);
|
|
||||||
testJSON('1.', true);
|
|
||||||
testJSON('1.0e', true);
|
|
||||||
testJSON('1.0e+', true);
|
|
||||||
testJSON('1.0e-', true);
|
|
||||||
testJSON('1.0e+z', true);
|
|
||||||
testJSON('1.0e-z', true);
|
|
||||||
testJSON('1.0ee', true);
|
|
||||||
testJSON('1.e1', true);
|
|
||||||
testJSON('1.e+1', true);
|
|
||||||
testJSON('1.e-1', true);
|
|
||||||
testJSON('.', true);
|
|
||||||
testJSON('.1', true);
|
|
||||||
testJSON('.1e', true);
|
|
||||||
testJSON('.1e1', true);
|
|
||||||
testJSON('.1e+1', true);
|
|
||||||
testJSON('.1e-1', true);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
testJSONSyntaxError('-');
|
||||||
|
testJSONSyntaxError('+');
|
||||||
print("Tests complete");
|
testJSONSyntaxError('-f');
|
||||||
|
testJSONSyntaxError('+f');
|
||||||
|
testJSONSyntaxError('00');
|
||||||
|
testJSONSyntaxError('01');
|
||||||
|
testJSONSyntaxError('1.');
|
||||||
|
testJSONSyntaxError('1.0e');
|
||||||
|
testJSONSyntaxError('1.0e+');
|
||||||
|
testJSONSyntaxError('1.0e-');
|
||||||
|
testJSONSyntaxError('1.0e+z');
|
||||||
|
testJSONSyntaxError('1.0e-z');
|
||||||
|
testJSONSyntaxError('1.0ee');
|
||||||
|
testJSONSyntaxError('1.e1');
|
||||||
|
testJSONSyntaxError('1.e+1');
|
||||||
|
testJSONSyntaxError('1.e-1');
|
||||||
|
testJSONSyntaxError('.');
|
||||||
|
testJSONSyntaxError('.1');
|
||||||
|
testJSONSyntaxError('.1e');
|
||||||
|
testJSONSyntaxError('.1e1');
|
||||||
|
testJSONSyntaxError('.1e+1');
|
||||||
|
testJSONSyntaxError('.1e-1');
|
||||||
|
@ -2,15 +2,10 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
testJSON('{"Numbers cannot have leading zeroes": 013}', true);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
testJSONSyntaxError('{"Numbers cannot have leading zeroes": 013}');
|
||||||
|
|
||||||
print("Tests complete");
|
|
||||||
|
@ -2,20 +2,15 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
testJSON("{}...", true);
|
|
||||||
testJSON('{"foo": truBBBB}', true);
|
|
||||||
testJSON('{foo: truBBBB}', true);
|
|
||||||
testJSON('{"foo": undefined}', true);
|
|
||||||
testJSON('{"foo": ]', true);
|
|
||||||
testJSON('{"foo', true);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
testJSONSyntaxError("{}...");
|
||||||
|
testJSONSyntaxError('{"foo": truBBBB}');
|
||||||
print("Tests complete");
|
testJSONSyntaxError('{foo: truBBBB}');
|
||||||
|
testJSONSyntaxError('{"foo": undefined}');
|
||||||
|
testJSONSyntaxError('{"foo": ]');
|
||||||
|
testJSONSyntaxError('{"foo');
|
||||||
|
@ -2,50 +2,45 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
testJSON('"Unterminated string literal', true);
|
|
||||||
testJSON('["Unclosed array"', true);
|
|
||||||
testJSON('{unquoted_key: "keys must be quoted"}', true);
|
|
||||||
testJSON('["extra comma",]', true);
|
|
||||||
testJSON('["double extra comma",,]', true);
|
|
||||||
testJSON('[ , "<-- missing value"]', true);
|
|
||||||
testJSON('["Comma after the close"],', true);
|
|
||||||
testJSON('["Extra close"]]', true);
|
|
||||||
testJSON('{"Extra comma": true,}', true);
|
|
||||||
testJSON('{"Extra value after close": true} "misplaced quoted value"', true);
|
|
||||||
testJSON('{"Illegal expression": 1 + 2}', true);
|
|
||||||
testJSON('{"Illegal invocation": alert()}', true);
|
|
||||||
testJSON('{"Numbers cannot be hex": 0x14}', true);
|
|
||||||
testJSON('["Illegal backslash escape: \\x15"]', true);
|
|
||||||
testJSON('[\\naked]', true);
|
|
||||||
testJSON('["Illegal backslash escape: \\017"]', true);
|
|
||||||
testJSON('{"Missing colon" null}', true);
|
|
||||||
testJSON('{"Double colon":: null}', true);
|
|
||||||
testJSON('{"Comma instead of colon", null}', true);
|
|
||||||
testJSON('["Colon instead of comma": false]', true);
|
|
||||||
testJSON('["Bad value", truth]', true);
|
|
||||||
testJSON("['single quote']", true);
|
|
||||||
testJSON('[" tab character in string "]', true);
|
|
||||||
testJSON('["tab\\ character\\ in\\ string\\ "]', true);
|
|
||||||
testJSON('["line\rbreak"]', true);
|
|
||||||
testJSON('["line\nbreak"]', true);
|
|
||||||
testJSON('["line\r\nbreak"]', true);
|
|
||||||
testJSON('["line\\\rbreak"]', true);
|
|
||||||
testJSON('["line\\\nbreak"]', true);
|
|
||||||
testJSON('["line\\\r\nbreak"]', true);
|
|
||||||
testJSON('[0e]', true);
|
|
||||||
testJSON('[0e+]', true);
|
|
||||||
testJSON('[0e+-1]', true);
|
|
||||||
testJSON('{"Comma instead of closing brace": true,', true);
|
|
||||||
testJSON('["mismatch"}', true);
|
|
||||||
testJSON('0{', true);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
testJSONSyntaxError('"Unterminated string literal');
|
||||||
|
testJSONSyntaxError('["Unclosed array"');
|
||||||
print("Tests complete");
|
testJSONSyntaxError('{unquoted_key: "keys must be quoted"}');
|
||||||
|
testJSONSyntaxError('["extra comma",]');
|
||||||
|
testJSONSyntaxError('["double extra comma",,]');
|
||||||
|
testJSONSyntaxError('[ , "<-- missing value"]');
|
||||||
|
testJSONSyntaxError('["Comma after the close"],');
|
||||||
|
testJSONSyntaxError('["Extra close"]]');
|
||||||
|
testJSONSyntaxError('{"Extra comma": true,}');
|
||||||
|
testJSONSyntaxError('{"Extra value after close": true} "misplaced quoted value"');
|
||||||
|
testJSONSyntaxError('{"Illegal expression": 1 + 2}');
|
||||||
|
testJSONSyntaxError('{"Illegal invocation": alert()}');
|
||||||
|
testJSONSyntaxError('{"Numbers cannot be hex": 0x14}');
|
||||||
|
testJSONSyntaxError('["Illegal backslash escape: \\x15"]');
|
||||||
|
testJSONSyntaxError('[\\naked]');
|
||||||
|
testJSONSyntaxError('["Illegal backslash escape: \\017"]');
|
||||||
|
testJSONSyntaxError('{"Missing colon" null}');
|
||||||
|
testJSONSyntaxError('{"Double colon":: null}');
|
||||||
|
testJSONSyntaxError('{"Comma instead of colon", null}');
|
||||||
|
testJSONSyntaxError('["Colon instead of comma": false]');
|
||||||
|
testJSONSyntaxError('["Bad value", truth]');
|
||||||
|
testJSONSyntaxError("['single quote']");
|
||||||
|
testJSONSyntaxError('[" tab character in string "]');
|
||||||
|
testJSONSyntaxError('["tab\\ character\\ in\\ string\\ "]');
|
||||||
|
testJSONSyntaxError('["line\rbreak"]');
|
||||||
|
testJSONSyntaxError('["line\nbreak"]');
|
||||||
|
testJSONSyntaxError('["line\r\nbreak"]');
|
||||||
|
testJSONSyntaxError('["line\\\rbreak"]');
|
||||||
|
testJSONSyntaxError('["line\\\nbreak"]');
|
||||||
|
testJSONSyntaxError('["line\\\r\nbreak"]');
|
||||||
|
testJSONSyntaxError('[0e]');
|
||||||
|
testJSONSyntaxError('[0e+]');
|
||||||
|
testJSONSyntaxError('[0e+-1]');
|
||||||
|
testJSONSyntaxError('{"Comma instead of closing brace": true,');
|
||||||
|
testJSONSyntaxError('["mismatch"}');
|
||||||
|
testJSONSyntaxError('0{');
|
||||||
|
@ -4,59 +4,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
testJSON('[', true);
|
|
||||||
testJSON('[1', true);
|
|
||||||
testJSON('[1,]', true);
|
|
||||||
testJSON('[1,{', true);
|
|
||||||
testJSON('[1,}', true);
|
|
||||||
testJSON('[1,{]', true);
|
|
||||||
testJSON('[1,}]', true);
|
|
||||||
testJSON('[1,{"', true);
|
|
||||||
testJSON('[1,}"', true);
|
|
||||||
testJSON('[1,{"\\', true);
|
|
||||||
testJSON('[1,}"\\', true);
|
|
||||||
testJSON('[1,"', true);
|
|
||||||
testJSON('[1,"\\', true);
|
|
||||||
|
|
||||||
testJSON('{', true);
|
testJSONSyntaxError('[');
|
||||||
testJSON('{1', true);
|
testJSONSyntaxError('[1');
|
||||||
testJSON('{,', true);
|
testJSONSyntaxError('[1,]');
|
||||||
testJSON('{"', true);
|
testJSONSyntaxError('[1,{');
|
||||||
testJSON('{"\\', true);
|
testJSONSyntaxError('[1,}');
|
||||||
testJSON('{"\\u', true);
|
testJSONSyntaxError('[1,{]');
|
||||||
testJSON('{"\\uG', true);
|
testJSONSyntaxError('[1,}]');
|
||||||
testJSON('{"\\u0', true);
|
testJSONSyntaxError('[1,{"');
|
||||||
testJSON('{"\\u01', true);
|
testJSONSyntaxError('[1,}"');
|
||||||
testJSON('{"\\u012', true);
|
testJSONSyntaxError('[1,{"\\');
|
||||||
testJSON('{"\\u0123', true);
|
testJSONSyntaxError('[1,}"\\');
|
||||||
testJSON('{"\\u0123"', true);
|
testJSONSyntaxError('[1,"');
|
||||||
testJSON('{"a"', true);
|
testJSONSyntaxError('[1,"\\');
|
||||||
testJSON('{"a"}', true);
|
|
||||||
testJSON('{"a":', true);
|
|
||||||
testJSON('{"a",}', true);
|
|
||||||
testJSON('{"a":}', true);
|
|
||||||
testJSON('{"a":,}', true);
|
|
||||||
testJSON('{"a":5,}', true);
|
|
||||||
testJSON('{"a":5,[', true);
|
|
||||||
testJSON('{"a":5,"', true);
|
|
||||||
testJSON('{"a":5,"', true);
|
|
||||||
testJSON('{"a":5,"\\', true);
|
|
||||||
testJSON("a[false ]".substring(1, 7) /* "[false" */, true);
|
|
||||||
|
|
||||||
testJSON('this', true);
|
testJSONSyntaxError('{');
|
||||||
|
testJSONSyntaxError('{1');
|
||||||
|
testJSONSyntaxError('{,');
|
||||||
|
testJSONSyntaxError('{"');
|
||||||
|
testJSONSyntaxError('{"\\');
|
||||||
|
testJSONSyntaxError('{"\\u');
|
||||||
|
testJSONSyntaxError('{"\\uG');
|
||||||
|
testJSONSyntaxError('{"\\u0');
|
||||||
|
testJSONSyntaxError('{"\\u01');
|
||||||
|
testJSONSyntaxError('{"\\u012');
|
||||||
|
testJSONSyntaxError('{"\\u0123');
|
||||||
|
testJSONSyntaxError('{"\\u0123"');
|
||||||
|
testJSONSyntaxError('{"a"');
|
||||||
|
testJSONSyntaxError('{"a"}');
|
||||||
|
testJSONSyntaxError('{"a":');
|
||||||
|
testJSONSyntaxError('{"a",}');
|
||||||
|
testJSONSyntaxError('{"a":}');
|
||||||
|
testJSONSyntaxError('{"a":,}');
|
||||||
|
testJSONSyntaxError('{"a":5,}');
|
||||||
|
testJSONSyntaxError('{"a":5,[');
|
||||||
|
testJSONSyntaxError('{"a":5,"');
|
||||||
|
testJSONSyntaxError('{"a":5,"');
|
||||||
|
testJSONSyntaxError('{"a":5,"\\');
|
||||||
|
testJSONSyntaxError("a[false ]".substring(1, 7));
|
||||||
|
|
||||||
testJSON('[1,{}]', false);
|
testJSONSyntaxError('this');
|
||||||
testJSON('{}', false);
|
|
||||||
testJSON('{"a":5}', false);
|
|
||||||
testJSON('{"\\u0123":5}', false);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
testJSON('[1,{}]');
|
||||||
|
testJSON('{}');
|
||||||
print("Tests complete");
|
testJSON('{"a":5}');
|
||||||
|
testJSON('{"\\u0123":5}');
|
||||||
|
@ -4,23 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
JSON.parse should reject U+0000 through U+001F
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
var gTestfile = 'small-codepoints.js';
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
var BUGNUMBER = 554079;
|
|
||||||
var summary = 'JSON.parse should reject U+0000 through U+001F';
|
|
||||||
|
|
||||||
print(BUGNUMBER + ": " + summary);
|
|
||||||
|
|
||||||
/**************
|
|
||||||
* BEGIN TEST *
|
|
||||||
**************/
|
|
||||||
|
|
||||||
for (var i = 0; i <= 0x1F; i++)
|
for (var i = 0; i <= 0x1F; i++)
|
||||||
testJSON('["a' + String.fromCharCode(i) + 'c"]', true);
|
testJSONSyntaxError('["a' + String.fromCharCode(i) + 'c"]');
|
||||||
|
@ -4,39 +4,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-JSON-shell.js]
|
includes: [sm/non262-JSON-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
'JSON.parse should reject {"a" : "b",} or [1,]
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
var gTestfile = 'trailing-comma.js';
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
var BUGNUMBER = 564621;
|
|
||||||
var summary = 'JSON.parse should reject {"a" : "b",} or [1,]';
|
|
||||||
|
|
||||||
print(BUGNUMBER + ": " + summary);
|
testJSON('[]');
|
||||||
|
testJSON('[1]');
|
||||||
|
testJSON('["a"]');
|
||||||
|
testJSON('{}');
|
||||||
|
testJSON('{"a":1}');
|
||||||
|
testJSON('{"a":"b"}');
|
||||||
|
testJSON('{"a":true}');
|
||||||
|
testJSON('[{}]');
|
||||||
|
|
||||||
/**************
|
testJSONSyntaxError('[1,]');
|
||||||
* BEGIN TEST *
|
testJSONSyntaxError('["a",]');
|
||||||
**************/
|
testJSONSyntaxError('{,}');
|
||||||
|
testJSONSyntaxError('{"a":1,}');
|
||||||
testJSON('[]', false);
|
testJSONSyntaxError('{"a":"b",}');
|
||||||
testJSON('[1]', false);
|
testJSONSyntaxError('{"a":true,}');
|
||||||
testJSON('["a"]', false);
|
testJSONSyntaxError('[{,}]');
|
||||||
testJSON('{}', false);
|
testJSONSyntaxError('[[1,]]');
|
||||||
testJSON('{"a":1}', false);
|
testJSONSyntaxError('[{"a":"b",}]');
|
||||||
testJSON('{"a":"b"}', false);
|
|
||||||
testJSON('{"a":true}', false);
|
|
||||||
testJSON('[{}]', false);
|
|
||||||
|
|
||||||
testJSON('[1,]', true);
|
|
||||||
testJSON('["a",]', true);
|
|
||||||
testJSON('{,}', true);
|
|
||||||
testJSON('{"a":1,}', true);
|
|
||||||
testJSON('{"a":"b",}', true);
|
|
||||||
testJSON('{"a":true,}', true);
|
|
||||||
testJSON('[{,}]', true);
|
|
||||||
testJSON('[[1,]]', true);
|
|
||||||
testJSON('[{"a":"b",}]', true);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user