test262/test/built-ins/JSON/parse/invalid-whitespace.js
jugglinmike 96c4e7730b Json whitespace (#724)
* Express JSON syntax tests with multiple assertions

When written with a single assertion, this test verifies only that "one
or more" of the Unicode points produces a SyntaxError. Re-factor the
test so that parsing behavior for each code point can be tested in
isolation.

* Re-introduce assertion

ECMAScript edition 2016 relies on the Unicode standard at version 8.0.0.
As part of a larger effort to update Test262 accordingly, the assertion
for the SyntaxError resulting from the use of the Mongolian Vowel
Separator (U+180E) was removed. However, ECMA-401 (The JSON Data
Interchange Format) continues to describe "insignificant whitespace" as
follows:

> Insignificant  whitespace  is  allowed  before  or  after  any  token.
> The  whitespace  characters  are:  character  tabulation  (U+0009),
> line  feed  (U+000A),  carriage  return (U+000D),  and  space
> (U+0020)

And because ECMA262 specifies step 2 of the `JSON.parse` algorithm as
follows:

> 2. Parse JText interpreted as UTF-16 encoded Unicode points (6.1.4) as
>    a JSON text as specified in ECMA-404. Throw a SyntaxError exception
>    if JText is not a valid JSON text as defined in that specification.

...the use of U+180E between JSON tokens should continue to produce a
SyntaxError, regardless of ECMA262's updated Unicode standard.

* fixup! Express JSON syntax tests with multiple assertions
2016-07-06 23:06:58 -07:00

76 lines
1.6 KiB
JavaScript

// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-json.parse
es6id: 24.3.1
es5id: 15.12.1.1-0-7
description: >
other category z spaces are not valid JSON whitespace as specified
by the production JSONWhitespace.
---*/
assert.throws(SyntaxError, function() {
JSON.parse('\u16801');
}, '\\u1680');
assert.throws(SyntaxError, function() {
JSON.parse('\u180e1');
}, '\\u180e');
assert.throws(SyntaxError, function() {
JSON.parse('\u20001');
}, '\\u2000');
assert.throws(SyntaxError, function() {
JSON.parse('\u20011');
}, '\\u2001');
assert.throws(SyntaxError, function() {
JSON.parse('\u20021');
}, '\\u2002');
assert.throws(SyntaxError, function() {
JSON.parse('\u20031');
}, '\\u2003');
assert.throws(SyntaxError, function() {
JSON.parse('\u20041');
}, '\\u2004');
assert.throws(SyntaxError, function() {
JSON.parse('\u20051');
}, '\\u2005');
assert.throws(SyntaxError, function() {
JSON.parse('\u20061');
}, '\\u2006');
assert.throws(SyntaxError, function() {
JSON.parse('\u20071');
}, '\\u2007');
assert.throws(SyntaxError, function() {
JSON.parse('\u20081');
}, '\\u2008');
assert.throws(SyntaxError, function() {
JSON.parse('\u20091');
}, '\\u2009');
assert.throws(SyntaxError, function() {
JSON.parse('\u200a1');
}, '\\u200a');
assert.throws(SyntaxError, function() {
JSON.parse('\u202f1');
}, '\\u202f');
assert.throws(SyntaxError, function() {
JSON.parse('\u205f1');
}, '\\u205f');
assert.throws(SyntaxError, function() {
JSON.parse('\u30001');
}, '\\u3000');