From d6e83453b20d823dbfec0951a3bcf7d1a9f2f86d Mon Sep 17 00:00:00 2001 From: Richard Gibson <richard.gibson@gmail.com> Date: Mon, 24 Sep 2018 01:48:41 -0400 Subject: [PATCH] Simplify and improve control character escaping tests --- .../built-ins/JSON/stringify/15.12.3-11-16.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-17.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-18.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-19.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-20.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-21.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-22.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-23.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-24.js | 56 ---------------- .../built-ins/JSON/stringify/15.12.3-11-25.js | 56 ---------------- .../JSON/stringify/string-escape-ascii.js | 66 +++++++++++++++++++ 11 files changed, 66 insertions(+), 560 deletions(-) delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-16.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-17.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-18.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-19.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-20.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-21.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-22.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-23.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-24.js delete mode 100644 test/built-ins/JSON/stringify/15.12.3-11-25.js create mode 100644 test/built-ins/JSON/stringify/string-escape-ascii.js diff --git a/test/built-ins/JSON/stringify/15.12.3-11-16.js b/test/built-ins/JSON/stringify/15.12.3-11-16.js deleted file mode 100644 index 23f89c2f9c..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-16.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-16 -description: > - JSON.stringify - stringifying an object where property name is the - union of all null character (The abstract operation Quote(value) - step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F": "John" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-17.js b/test/built-ins/JSON/stringify/15.12.3-11-17.js deleted file mode 100644 index 9723236294..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-17.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-17 -description: > - JSON.stringify - stringifying an object where property name starts - with the union of all null character (The abstract operation - Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001Fname": "John" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-18.js b/test/built-ins/JSON/stringify/15.12.3-11-18.js deleted file mode 100644 index 6766a4e199..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-18.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-18 -description: > - JSON.stringify - stringifying an object where property name ends - with the union of all null character (The abstract operation - Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F": "John" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-19.js b/test/built-ins/JSON/stringify/15.12.3-11-19.js deleted file mode 100644 index 052e394f27..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-19.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-19 -description: > - JSON.stringify - stringifying an object where property name starts - and ends with the union of all null character (The abstract - operation Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001Fname\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F": "John" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-20.js b/test/built-ins/JSON/stringify/15.12.3-11-20.js deleted file mode 100644 index 8c9bc27838..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-20.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-20 -description: > - JSON.stringify - stringifying an object where property name - middles with the union of all null character (The abstract - operation Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "na\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001Fme": "John" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-21.js b/test/built-ins/JSON/stringify/15.12.3-11-21.js deleted file mode 100644 index ca7e598d61..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-21.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-21 -description: > - JSON.stringify - stringifying an object where property value is - the union of all null character (The abstract operation - Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-22.js b/test/built-ins/JSON/stringify/15.12.3-11-22.js deleted file mode 100644 index eec1325004..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-22.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-22 -description: > - JSON.stringify - stringifying an object where property value - starts with the union of all null character (The abstract - operation Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001FJohn" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-23.js b/test/built-ins/JSON/stringify/15.12.3-11-23.js deleted file mode 100644 index 982968f34d..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-23.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-23 -description: > - JSON.stringify - stringifying an object where property value ends - with the union of all null character (The abstract operation - Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name": "John\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-24.js b/test/built-ins/JSON/stringify/15.12.3-11-24.js deleted file mode 100644 index 3fc4140a2c..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-24.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-24 -description: > - JSON.stringify - stringifying an object where property value - starts and ends with the union of all null character (The abstract - operation Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001FJohn\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/15.12.3-11-25.js b/test/built-ins/JSON/stringify/15.12.3-11-25.js deleted file mode 100644 index 9a26fa4181..0000000000 --- a/test/built-ins/JSON/stringify/15.12.3-11-25.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.12.3-11-25 -description: > - JSON.stringify - stringifying an object where property value - middles with the union of all null character (The abstract - operation Quote(value) step 2.c) ----*/ - -var result = true; - -var expectedNullChars = new Array(); -expectedNullChars[0] = "\\u0000"; -expectedNullChars[1] = "\\u0001"; -expectedNullChars[2] = "\\u0002"; -expectedNullChars[3] = "\\u0003"; -expectedNullChars[4] = "\\u0004"; -expectedNullChars[5] = "\\u0005"; -expectedNullChars[6] = "\\u0006"; -expectedNullChars[7] = "\\u0007"; -expectedNullChars[8] = "\\b"; -expectedNullChars[9] = "\\t"; -expectedNullChars[10] = "\\n"; -expectedNullChars[11] = "\\u000b"; -expectedNullChars[12] = "\\f"; -expectedNullChars[13] = "\\r"; -expectedNullChars[14] = "\\u000e"; -expectedNullChars[15] = "\\u000f"; -expectedNullChars[16] = "\\u0010"; -expectedNullChars[17] = "\\u0011"; -expectedNullChars[18] = "\\u0012"; -expectedNullChars[19] = "\\u0013"; -expectedNullChars[20] = "\\u0014"; -expectedNullChars[21] = "\\u0015"; -expectedNullChars[22] = "\\u0016"; -expectedNullChars[23] = "\\u0017"; -expectedNullChars[24] = "\\u0018"; -expectedNullChars[25] = "\\u0019"; -expectedNullChars[26] = "\\u001a"; -expectedNullChars[27] = "\\u001b"; -expectedNullChars[28] = "\\u001c"; -expectedNullChars[29] = "\\u001d"; -expectedNullChars[30] = "\\u001e"; -expectedNullChars[31] = "\\u001f"; - -for (var index in expectedNullChars) { - - var str = JSON.stringify({ - "name": "Jo\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001Fhn" - }); - result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1); -} - -assert(result, 'result !== true'); diff --git a/test/built-ins/JSON/stringify/string-escape-ascii.js b/test/built-ins/JSON/stringify/string-escape-ascii.js new file mode 100644 index 0000000000..5751c43fdb --- /dev/null +++ b/test/built-ins/JSON/stringify/string-escape-ascii.js @@ -0,0 +1,66 @@ +// Copyright (c) 2018 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-quotejsonstring +description: > + JSON.stringify property names and values containing ASCII + characters that require escaping +---*/ + +var char_to_json = { + '"': '\\"', + "\\": "\\\\", + "\x00": "\\u0000", + "\x01": "\\u0001", + "\x02": "\\u0002", + "\x03": "\\u0003", + "\x04": "\\u0004", + "\x05": "\\u0005", + "\x06": "\\u0006", + "\x07": "\\u0007", + "\x08": "\\b", + "\x09": "\\t", + "\x0A": "\\n", + "\x0B": "\\u000b", + "\x0C": "\\f", + "\x0D": "\\r", + "\x0E": "\\u000e", + "\x0F": "\\u000f", + "\x10": "\\u0010", + "\x11": "\\u0011", + "\x12": "\\u0012", + "\x13": "\\u0013", + "\x14": "\\u0014", + "\x15": "\\u0015", + "\x16": "\\u0016", + "\x17": "\\u0017", + "\x18": "\\u0018", + "\x19": "\\u0019", + "\x1A": "\\u001a", + "\x1B": "\\u001b", + "\x1C": "\\u001c", + "\x1D": "\\u001d", + "\x1E": "\\u001e", + "\x1F": "\\u001f" +} + +var chars = Object.keys(char_to_json).join(""); +var chars_reversed = Object.keys(char_to_json).reverse().join(""); +var jsonChars = Object.values(char_to_json).join(""); +var jsonChars_reversed = Object.values(char_to_json).reverse().join(""); +var json = JSON.stringify({ + ["name" + chars + chars_reversed]: chars_reversed + chars + "value" +}); + +for (var char in char_to_json) { + var count = json.split(char_to_json[char]).length - 1; + assert.sameValue(count, 4, + "Every ASCII 0x" + char.charCodeAt(0).toString(16) + " serializes to " + char_to_json[char]); +} + +assert.sameValue( + json, + `{"${"name" + jsonChars + jsonChars_reversed}":"${jsonChars_reversed + jsonChars + "value"}"}`, + "JSON.stringify(objectUsingControlCharacters)" +); -- GitLab