mirror of https://github.com/tc39/test262.git
51 lines
5.6 KiB
JSON
51 lines
5.6 KiB
JSON
{
|
|
"testCollection": {
|
|
"name": "15.4.5.2_length",
|
|
"numTests": 7,
|
|
"tests": [
|
|
{
|
|
"section": "15.4.5.2, 15.4",
|
|
"description": "Checking boundary points",
|
|
"test": "//CHECK#1\nvar x = [];\nif (x.length !== 0) { \n $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); \n}\n\n//CHECK#2\nx[0] = 1;\nif (x.length !== 1) { \n $ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length));\n}\n\n//CHECK#3\nx[1] = 1;\nif (x.length !== 2) { \n $ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length));\n}\n\n//CHECK#4\nx[2147483648] = 1;\nif (x.length !== 2147483649) { \n $ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x.length === 2147483649. Actual: ' + (x.length));\n}\n\n//CHECK#5\nx[4294967294] = 1;\nif (x.length !== 4294967295) { \n $ERROR('#5: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x[42949672954] = 1; x.length === 4294967295. Actual: ' + (x.length));\n}\n",
|
|
"id": "S15.4.5.2_A1_T1"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4",
|
|
"description": "P = \"2^32 - 1\" is not index array",
|
|
"test": "//CHECK#1\nvar x = [];\nx[4294967295] = 1;\nif (x.length !== 0) { \n $ERROR('#1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length)); \n}\n\n//CHECK#2\nvar y =[];\ny[1] = 1;\ny[4294967295] = 1;\nif (y.length !== 2) { \n $ERROR('#2: y = []; y[1] = 1; y[4294967295] = 1; y.length === 2. Actual: ' + (y.length));\n}\n",
|
|
"id": "S15.4.5.2_A1_T2"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4",
|
|
"description": "Checking length property",
|
|
"test": "//CHECK#1\nvar x = [];\nif (x.length !== 0) { \n $ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length)); \n}\n\n//CHECK#2\nx[0] = 1;\nif (x.length !== 1) { \n $ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length));\n}\n\n//CHECK#3\nx[1] = 1;\nif (x.length !== 2) { \n $ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length));\n}\n\n//CHECK#4\nx[9] = 1;\nif (x.length !== 10) { \n $ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[9] = 1; x.length === 10. Actual: ' + (x.length));\n}\n",
|
|
"id": "S15.4.5.2_A2_T1"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4",
|
|
"description": "If new length greater than the name of every property whose name\nis an array index",
|
|
"test": "//CHECK#1\nvar x = [];\nx.length = 1;\nif (x.length !== 1) { \n $ERROR('#1: x = []; x.length = 1; x.length === 1. Actual: ' + (x.length)); \n}\n\n//CHECK#2\nx[5] = 1;\nx.length = 10;\nif (x.length !== 10) { \n $ERROR('#2: x = []; x.length = 1; x[5] = 1; x.length = 10; x.length === 10. Actual: ' + (x.length));\n}\n\n//CHECK#3\nif (x[5] !== 1) { \n $ERROR('#3: x = []; x.length = 1; x[5] = 1; x.length = 10; x[5] = 1');\n}\n",
|
|
"id": "S15.4.5.2_A3_T1"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4",
|
|
"description": "If new length greater than the name of every property whose name\nis an array index",
|
|
"test": "//CHECK#1\nvar x = [];\nx[1] = 1;\nx[3] = 3;\nx[5] = 5;\nx.length = 4;\nif (x.length !== 4) { \n $ERROR('#1: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length === 4. Actual: ' + (x.length)); \n}\n\n//CHECK#2\nif (x[5] !== undefined) { \n $ERROR('#2: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[5] === undefined. Actual: ' + (x[5]));\n}\n\n//CHECK#3\nif (x[3] !== 3) { \n $ERROR('#3: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[3] === 3. Actual: ' + (x[3]));\n}\n\n//CHECK#4\nx.length = new Number(6);\nif (x[5] !== undefined) { \n $ERROR('#4: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x[5] === undefined. Actual: ' + (x[5]));\n}\n\n//CHECK#5\nx.length = 0;\nif (x[0] !== undefined) { \n $ERROR('#5: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x[0] === undefined. Actual: ' + (x[0]));\n}\n\n//CHECK#6\nx.length = 1;\nif (x[1] !== undefined) { \n $ERROR('#6: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x.length = 1; x[1] === undefined. Actual: ' + (x[1]));\n}\n",
|
|
"id": "S15.4.5.2_A3_T2"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4.2.2",
|
|
"description": "[[Put]] (length, 4294967296)",
|
|
"test": "//CHECK#1\nvar x = [];\nx.length = 4294967295;\nif (x.length !== 4294967295) { \n $ERROR('#1: x = []; x.length = 4294967295; x.length === 4294967295'); \n}\n\n//CHECK#2\ntry {\n x = [];\n x.length = 4294967296;\n $ERROR('#2.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));\n} catch(e) { \n if ((e instanceof RangeError) !== true) {\n $ERROR('#2.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e));\n } \n}\n",
|
|
"id": "S15.4.5.2_A3_T3"
|
|
},
|
|
{
|
|
"section": "15.4.5.2, 15.4.2.2",
|
|
"description": "If new length greater than the name of every property whose name\nis an array index",
|
|
"test": "//CHECK#1\nvar x = [0,1,2]; \nx[4294967294] = 4294967294; \nx.length = 2;\n\n//CHECK#1\nif (x[0] !== 0) { \n $ERROR('#1: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[0] === 0. Actual: ' + (x[0])); \n}\n\n//CHECK#2\nif (x[1] !== 1) { \n $ERROR('#2: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[1] === 1. Actual: ' + (x[1])); \n}\n\n//CHECK#3\nif (x[2] !== undefined) { \n $ERROR('#3: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[2] === undefined. Actual: ' + (x[2])); \n}\n\n//CHECK#4\nif (x[4294967294] !== undefined) { \n $ERROR('#4: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[4294967294] === undefined. Actual: ' + (x[4294967294])); \n}\n\n",
|
|
"id": "S15.4.5.2_A3_T4"
|
|
}
|
|
]
|
|
}
|
|
}
|