mirror of https://github.com/tc39/test262.git
51 lines
4.2 KiB
JSON
51 lines
4.2 KiB
JSON
{
|
|
"testCollection": {
|
|
"name": "15.4.2.1_new_Array",
|
|
"numTests": 7,
|
|
"tests": [
|
|
{
|
|
"section": "15.4.2.1, 15.2.4.5",
|
|
"description": "Create new property of Array.prototype. When new Array object has this property",
|
|
"test": "//CHECK#1\nArray.prototype.myproperty = 1;\nvar x = new Array(); \nif (x.myproperty !== 1) {\n $ERROR('#1: Array.prototype.myproperty = 1; var x = new Array(); x.myproperty === 1. Actual: ' + (x.myproperty));\n}\n\n//CHECK#2\nif (x.hasOwnProperty('myproperty') !== false) {\n $ERROR('#2: Array.prototype.myproperty = 1; var x = new Array(); x.hasOwnProperty(\\'myproperty\\') === false. Actual: ' + (x.hasOwnProperty('myproperty')));\n}\n",
|
|
"id": "S15.4.2.1_A1.1_T1"
|
|
},
|
|
{
|
|
"section": "15.4.2.1, 15.2.4.2",
|
|
"description": "Array.prototype.toString = Object.prototype.toString",
|
|
"test": "//CHECK#1\nArray.prototype.toString = Object.prototype.toString;\nvar x = new Array(); \nif (x.toString() !== \"[object \" + \"Array\" + \"]\") {\n $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = new Array(); x.toString() === \"[object \" + \"Array\" + \"]\". Actual: ' + (x.toString()));\n}\n\n//CHECK#2\nArray.prototype.toString = Object.prototype.toString;\nvar x = new Array(0,1,2); \nif (x.toString() !== \"[object \" + \"Array\" + \"]\") {\n $ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = new Array(0,1,2); x.toString() === \"[object \" + \"Array\" + \"]\". Actual: ' + (x.toString()));\n}\n\n",
|
|
"id": "S15.4.2.1_A1.1_T2"
|
|
},
|
|
{
|
|
"section": "15.4.2.1, 15.2.4.6",
|
|
"description": "Checking use isPrototypeOf",
|
|
"test": "//CHECK#1\nif (Array.prototype.isPrototypeOf(new Array()) !== true) {\n $ERROR('#1: Array.prototype.isPrototypeOf(new Array()) === true. Actual: ' + (Array.prototype.isPrototypeOf(new Array())));\n}\n\n",
|
|
"id": "S15.4.2.1_A1.1_T3"
|
|
},
|
|
{
|
|
"section": "15.4.2.1, 15.2.4.2",
|
|
"description": "Checking use Object.prototype.toString",
|
|
"test": "//CHECK#1\nvar x = new Array(); \nx.getClass = Object.prototype.toString;\nif (x.getClass() !== \"[object \" + \"Array\" + \"]\") {\n $ERROR('#1: var x = new Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));\n}\n\n//CHECK#2\nvar x = new Array(0,1,2); \nx.getClass = Object.prototype.toString;\nif (x.getClass() !== \"[object \" + \"Array\" + \"]\") {\n $ERROR('#2: var x = new Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));\n}\n",
|
|
"id": "S15.4.2.1_A1.2_T1"
|
|
},
|
|
{
|
|
"section": "15.4.2.1",
|
|
"description": "Checking case when Array constructor is given one argument",
|
|
"test": "var x = new Array(2);\n\n//CHECK#1\nif (x.length === 1) {\n $ERROR('#1: var x = new Array(2); x.length !== 1');\n}\n\n//CHECK#2\nif (x[0] === 2) {\n $ERROR('#2: var x = new Array(2); x[0] !== 2');\n}\n",
|
|
"id": "S15.4.2.1_A1.3_T1"
|
|
},
|
|
{
|
|
"section": "15.4.2.1",
|
|
"description": "Array constructor is given no arguments or at least two arguments",
|
|
"test": "//CHECK#1\nif (new Array().length !== 0) {\n $ERROR('#1: new Array().length === 0. Actual: ' + (new Array().length));\n}\n\n//CHECK#2\nif (new Array(0,1,0,1).length !== 4) {\n $ERROR('#2: new Array(0,1,0,1).length === 4. Actual: ' + (new Array(0,1,0,1).length));\n}\n\n//CHECK#3\nif (new Array(undefined, undefined).length !== 2) {\n $ERROR('#3: new Array(undefined, undefined).length === 2. Actual: ' + (new Array(undefined, undefined).length));\n}\n",
|
|
"id": "S15.4.2.1_A2.1_T1"
|
|
},
|
|
{
|
|
"section": "15.4.2.1",
|
|
"description": "Checking correct work this algorithm",
|
|
"test": "//CHECK#\nvar x = new Array(\n0,1,2,3,4,5,6,7,8,9,\n10,11,12,13,14,15,16,17,18,19,\n20,21,22,23,24,25,26,27,28,29,\n30,31,32,33,34,35,36,37,38,39,\n40,41,42,43,44,45,46,47,48,49,\n50,51,52,53,54,55,56,57,58,59,\n60,61,62,63,64,65,66,67,68,69,\n70,71,72,73,74,75,76,77,78,79,\n80,81,82,83,84,85,86,87,88,89,\n90,91,92,93,94,95,96,97,98,99\n);\n\nfor (var i = 0; i < 100; i++) {\n var result = true;\n if (x[i] !== i) {\n result = false;\n }\n}\n\nif (result !== true) {\n $ERROR('#1: x[i] === i. Actual: ' + (x[i]));\n} \n",
|
|
"id": "S15.4.2.1_A2.2_T1"
|
|
}
|
|
]
|
|
}
|
|
}
|