Replace runTestCase with assert helpers [test/built-ins/JSON]

This commit is contained in:
André Bargull 2015-08-06 18:25:42 +02:00
parent bec8782918
commit 8ea6a7e374
34 changed files with 64 additions and 195 deletions

View File

@ -8,13 +8,8 @@ info: >
4.2 calls out JSON as one of the built-in objects. 4.2 calls out JSON as one of the built-in objects.
es5id: 15.12-0-1 es5id: 15.12-0-1
description: JSON must be a built-in object description: JSON must be a built-in object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var o = JSON; var o = JSON;
if (typeof(o) === "object") {
return true; assert.sameValue(typeof(o), "object", 'typeof(o)');
}
}
runTestCase(testcase);

View File

@ -10,18 +10,13 @@ info: >
JSON, and we should not be able to enumerate them. JSON, and we should not be able to enumerate them.
es5id: 15.12-0-4 es5id: 15.12-0-4
description: JSON object's properties must be non enumerable description: JSON object's properties must be non enumerable
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var o = JSON; var o = JSON;
var i = 0; var i = 0;
for (var p in o) { for (var p in o) {
i++; i++;
} }
if (i === 0) {
return true; assert.sameValue(i, 0, 'i');
}
}
runTestCase(testcase);

View File

@ -4,16 +4,10 @@
/*--- /*---
es5id: 15.12.1.1-0-9 es5id: 15.12.1.1-0-9
description: Whitespace characters can appear before/after any JSONtoken description: Whitespace characters can appear before/after any JSONtoken
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
JSON.parse('\t\r \n{\t\r \n'+ JSON.parse('\t\r \n{\t\r \n'+
'"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' + '"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' +
'"prop2"\t\r \n:\t\r \n'+ '"prop2"\t\r \n:\t\r \n'+
'[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]'+ '[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]'+
'\t\r \n}\t\r \n'); // should JOSN parse without error '\t\r \n}\t\r \n'); // should JOSN parse without error
return true;
}
runTestCase(testcase);

View File

@ -15,14 +15,8 @@ info: >
taking 2 parameters. taking 2 parameters.
es5id: 15.12.2-0-1 es5id: 15.12.2-0-1
description: JSON.parse must exist as a function description: JSON.parse must exist as a function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = JSON.parse; var f = JSON.parse;
if (typeof(f) === "function") { assert.sameValue(typeof(f), "function", 'typeof(f)');
return true;
}
}
runTestCase(testcase);

View File

@ -15,14 +15,9 @@ info: >
taking 2 parameters. taking 2 parameters.
es5id: 15.12.2-0-2 es5id: 15.12.2-0-2
description: JSON.parse must exist as a function taking 2 parameters description: JSON.parse must exist as a function taking 2 parameters
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = JSON.parse; var f = JSON.parse;
if (typeof(f) === "function" && f.length === 2) { assert.sameValue(typeof(f), "function", 'typeof(f)');
return true; assert.sameValue(f.length, 2, 'f.length');
}
}
runTestCase(testcase);

View File

@ -8,12 +8,9 @@ info: >
should be able to delete (8.6.2.5) the stringify and parse properties. should be able to delete (8.6.2.5) the stringify and parse properties.
es5id: 15.12.2-0-3 es5id: 15.12.2-0-3
description: JSON.parse must be deletable (configurable) description: JSON.parse must be deletable (configurable)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var o = JSON; var o = JSON;
var desc = Object.getOwnPropertyDescriptor(o, "parse"); var desc = Object.getOwnPropertyDescriptor(o, "parse");
return desc.configurable === true;
} assert.sameValue(desc.configurable, true, 'desc.configurable');
runTestCase(testcase);

View File

@ -15,14 +15,8 @@ info: >
taking 3 parameters. taking 3 parameters.
es5id: 15.12.3-0-1 es5id: 15.12.3-0-1
description: JSON.stringify must exist as be a function description: JSON.stringify must exist as be a function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = JSON.stringify; var f = JSON.stringify;
if (typeof(f) === "function") { assert.sameValue(typeof(f), "function", 'typeof(f)');
return true;
}
}
runTestCase(testcase);

View File

@ -15,14 +15,9 @@ info: >
taking 3 parameters. taking 3 parameters.
es5id: 15.12.3-0-2 es5id: 15.12.3-0-2
description: JSON.stringify must exist as be a function taking 3 parameters description: JSON.stringify must exist as be a function taking 3 parameters
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = JSON.stringify; var f = JSON.stringify;
if (typeof(f) === "function" && f.length === 3) { assert.sameValue(typeof(f), "function", 'typeof(f)');
return true; assert.sameValue(f.length, 3, 'f.length');
}
}
runTestCase(testcase);

View File

@ -8,14 +8,9 @@ info: >
should be able to delete (8.6.2.5) the stringify and parse properties. should be able to delete (8.6.2.5) the stringify and parse properties.
es5id: 15.12.3-0-3 es5id: 15.12.3-0-3
description: JSON.stringify must be deletable (configurable) description: JSON.stringify must be deletable (configurable)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var o = JSON; var o = JSON;
var desc = Object.getOwnPropertyDescriptor(o, "stringify"); var desc = Object.getOwnPropertyDescriptor(o, "stringify");
if (desc.configurable === true) {
return true; assert.sameValue(desc.configurable, true, 'desc.configurable');
}
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property name is the JSON.stringify - stringifying an object where property name is the
union of all null character (The abstract operation Quote(value) union of all null character (The abstract operation Quote(value)
step 2.c) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property name starts JSON.stringify - stringifying an object where property name starts
with the union of all null character (The abstract operation with the union of all null character (The abstract operation
Quote(value) step 2.c) Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property name ends JSON.stringify - stringifying an object where property name ends
with the union of all null character (The abstract operation with the union of all null character (The abstract operation
Quote(value) step 2.c) Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property name starts JSON.stringify - stringifying an object where property name starts
and ends with the union of all null character (The abstract and ends with the union of all null character (The abstract
operation Quote(value) step 2.c) operation Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property name JSON.stringify - stringifying an object where property name
middles with the union of all null character (The abstract middles with the union of all null character (The abstract
operation Quote(value) step 2.c) operation Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property value is JSON.stringify - stringifying an object where property value is
the union of all null character (The abstract operation the union of all null character (The abstract operation
Quote(value) step 2.c) Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property value JSON.stringify - stringifying an object where property value
starts with the union of all null character (The abstract starts with the union of all null character (The abstract
operation Quote(value) step 2.c) operation Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property value ends JSON.stringify - stringifying an object where property value ends
with the union of all null character (The abstract operation with the union of all null character (The abstract operation
Quote(value) step 2.c) Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property value JSON.stringify - stringifying an object where property value
starts and ends with the union of all null character (The abstract starts and ends with the union of all null character (The abstract
operation Quote(value) step 2.c) operation Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
JSON.stringify - stringifying an object where property value JSON.stringify - stringifying an object where property value
middles with the union of all null character (The abstract middles with the union of all null character (The abstract
operation Quote(value) step 2.c) operation Quote(value) step 2.c)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var result = true; var result = true;
var expectedNullChars = new Array(); var expectedNullChars = new Array();
@ -53,6 +50,5 @@ function testcase() {
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" }); 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); result = (result && str.indexOf(expectedNullChars[index]) !== -1 && str.indexOf(expectedNullChars[index]) !== -1);
} }
return result;
} assert(result, 'result !== true');
runTestCase(testcase);

View File

@ -6,16 +6,13 @@ es5id: 15.12.3-11-26
description: > description: >
JSON.stringify - the last element of the concatenation is ']' (The JSON.stringify - the last element of the concatenation is ']' (The
abstract operation JA(value) step 10.b.iii) abstract operation JA(value) step 10.b.iii)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arrObj = []; var arrObj = [];
arrObj[0] = "a"; arrObj[0] = "a";
arrObj[1] = "b"; arrObj[1] = "b";
arrObj[2] = "c"; arrObj[2] = "c";
var jsonText = JSON.stringify(arrObj, undefined, "").toString(); var jsonText = JSON.stringify(arrObj, undefined, "").toString();
return jsonText.charAt(jsonText.length - 1) === "]";
} assert.sameValue(jsonText.charAt(jsonText.length - 1), "]", 'jsonText.charAt(jsonText.length - 1)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-5-a-i-1
description: > description: >
JSON.stringify converts Number wrapper object space aruguments to JSON.stringify converts Number wrapper object space aruguments to
Number values Number values
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj,null, new Number(5))=== JSON.stringify(obj,null, 5);
} assert.sameValue(JSON.stringify(obj,null, new Number(5)), JSON.stringify(obj,null, 5), 'JSON.stringify(obj,null, new Number(5))');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-5-b-i-1
description: > description: >
JSON.stringify converts String wrapper object space aruguments to JSON.stringify converts String wrapper object space aruguments to
String values String values
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj,null, new String('xxx'))=== JSON.stringify(obj,null, 'xxx');
} assert.sameValue(JSON.stringify(obj,null, new String('xxx')), JSON.stringify(obj,null, 'xxx'), 'JSON.stringify(obj,null, new String("xxx"))');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-6-a-1
description: > description: >
JSON.stringify treats numeric space arguments greater than 10 the JSON.stringify treats numeric space arguments greater than 10 the
same as a space argument of 10. same as a space argument of 10.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj,null, 10)=== JSON.stringify(obj,null, 100);
} assert.sameValue(JSON.stringify(obj,null, 10), JSON.stringify(obj,null, 100), 'JSON.stringify(obj,null, 10)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-6-a-2
description: > description: >
JSON.stringify truccates non-integer numeric space arguments to JSON.stringify truccates non-integer numeric space arguments to
their integer part. their integer part.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj,null, 5.99999)=== JSON.stringify(obj,null, 5);
} assert.sameValue(JSON.stringify(obj,null, 5.99999), JSON.stringify(obj,null, 5), 'JSON.stringify(obj,null, 5.99999)');
runTestCase(testcase);

View File

@ -6,13 +6,10 @@ es5id: 15.12.3-6-b-4
description: > description: >
JSON.stringify treats numeric space arguments (in the range 1..10) JSON.stringify treats numeric space arguments (in the range 1..10)
is equivalent to a string of spaces of that length. is equivalent to a string of spaces of that length.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
var fiveSpaces = ' '; var fiveSpaces = ' ';
// '12345' // '12345'
return JSON.stringify(obj,null, 5)=== JSON.stringify(obj, null, fiveSpaces);
} assert.sameValue(JSON.stringify(obj,null, 5), JSON.stringify(obj, null, fiveSpaces), 'JSON.stringify(obj,null, 5)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-7-a-1
description: > description: >
JSON.stringify only uses the first 10 characters of a string space JSON.stringify only uses the first 10 characters of a string space
arguments. arguments.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj,null, '0123456789xxxxxxxxx')=== JSON.stringify(obj,null, '0123456789');
} assert.sameValue(JSON.stringify(obj,null, '0123456789xxxxxxxxx'), JSON.stringify(obj,null, '0123456789'), 'JSON.stringify(obj,null, "0123456789xxxxxxxxx")');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-8-a-1
description: > description: >
JSON.stringify treats an empty string space argument the same as a JSON.stringify treats an empty string space argument the same as a
missing space argument. missing space argument.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj)=== JSON.stringify(obj,null, '');
} assert.sameValue(JSON.stringify(obj), JSON.stringify(obj,null, ''), 'JSON.stringify(obj)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-8-a-2
description: > description: >
JSON.stringify treats an Boolean space argument the same as a JSON.stringify treats an Boolean space argument the same as a
missing space argument. missing space argument.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj)=== JSON.stringify(obj,null, true);
} assert.sameValue(JSON.stringify(obj), JSON.stringify(obj,null, true), 'JSON.stringify(obj)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-8-a-3
description: > description: >
JSON.stringify treats an null space argument the same as a missing JSON.stringify treats an null space argument the same as a missing
space argument. space argument.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj)=== JSON.stringify(obj,null, null);
} assert.sameValue(JSON.stringify(obj), JSON.stringify(obj,null, null), 'JSON.stringify(obj)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-8-a-4
description: > description: >
JSON.stringify treats an Boolean wrapper space argument the same JSON.stringify treats an Boolean wrapper space argument the same
as a missing space argument. as a missing space argument.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj)=== JSON.stringify(obj,null, new Boolean(true));
} assert.sameValue(JSON.stringify(obj), JSON.stringify(obj,null, new Boolean(true)), 'JSON.stringify(obj)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.12.3-8-a-5
description: > description: >
JSON.stringify treats non-Number or String object space arguments JSON.stringify treats non-Number or String object space arguments
the same as a missing space argument. the same as a missing space argument.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'}; var obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
return JSON.stringify(obj)=== JSON.stringify(obj,null, obj);
} assert.sameValue(JSON.stringify(obj), JSON.stringify(obj,null, obj), 'JSON.stringify(obj)');
runTestCase(testcase);

View File

@ -6,14 +6,11 @@ es5id: 15.12.3_2-2-b-i-1
description: > description: >
JSON.stringify converts string wrapper objects returned from a JSON.stringify converts string wrapper objects returned from a
toJSON call to literal strings. toJSON call to literal strings.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { var obj = {
prop:42, prop:42,
toJSON: function () {return 'fortytwo objects'} toJSON: function () {return 'fortytwo objects'}
}; };
return JSON.stringify([obj]) === '["fortytwo objects"]';
} assert.sameValue(JSON.stringify([obj]), '["fortytwo objects"]', 'JSON.stringify([obj])');
runTestCase(testcase);

View File

@ -6,14 +6,11 @@ es5id: 15.12.3_2-2-b-i-2
description: > description: >
JSON.stringify converts Number wrapper objects returned from a JSON.stringify converts Number wrapper objects returned from a
toJSON call to literal Number. toJSON call to literal Number.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { var obj = {
prop:42, prop:42,
toJSON: function () {return new Number(42)} toJSON: function () {return new Number(42)}
}; };
return JSON.stringify([obj]) === '[42]';
} assert.sameValue(JSON.stringify([obj]), '[42]', 'JSON.stringify([obj])');
runTestCase(testcase);

View File

@ -6,14 +6,11 @@ es5id: 15.12.3_2-2-b-i-3
description: > description: >
JSON.stringify converts Boolean wrapper objects returned from a JSON.stringify converts Boolean wrapper objects returned from a
toJSON call to literal Boolean values. toJSON call to literal Boolean values.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { var obj = {
prop:42, prop:42,
toJSON: function () {return new Boolean(true)} toJSON: function () {return new Boolean(true)}
}; };
return JSON.stringify([obj]) === '[true]';
} assert.sameValue(JSON.stringify([obj]), '[true]', 'JSON.stringify([obj])');
runTestCase(testcase);