aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.4_Array_Objects.json
blob: 36ce5b437ec1ed8e80893b14e7c911454d79e6b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
 "testCollection": {
  "name": "15.4_Array_Objects",
  "numTests": 10,
  "tests": [
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for boolean primitive",
    "test": "//CHECK#1\nx = [];\nx[true] = 1;\nif (x[1] !== undefined) {\n  $ERROR('#1: x = []; x[true] = 1; x[1] === undefined. Actual: ' + (x[1]));  \n}\n\n//CHECK#2\nif (x[\"true\"] !== 1) {\n  $ERROR('#2: x = []; x[true] = 1; x[\"true\"] === 1. Actual: ' + (x[\"true\"]));  \n}\n\n//CHECK#3\nx[false] = 0;\nif (x[0] !== undefined) {\n  $ERROR('#3: x = []; x[true] = 1; x[false] = 0; x[0] === undefined. Actual: ' + (x[0]));  \n}\n\n//CHECK#4\nif (x[\"false\"] !== 0) {\n  $ERROR('#4: x = []; x[false] = 1; x[\"false\"] === 0. Actual: ' + (x[\"false\"]));  \n}\n",
    "id": "S15.4_A1.1_T1"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Array index is power of two",
    "test": "//CHECK#\nx = [];\nk = 1;\nfor (i = 0; i < 32; i++) {\n  k = k * 2;\n  x[k - 2] = k;  \n}\n\nk = 1;\nfor (i = 0; i < 32; i++) {\n  k = k * 2;\n  if (x[k - 2] !== k) {\n    $ERROR('#' + (k - 2) + ': ');\n  }     \n}\n",
    "id": "S15.4_A1.1_T10"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for number primitive",
    "test": "//CHECK#1\nx = [];\nx[NaN] = 1;\nif (x[0] !== undefined) {\n  $ERROR('#1: x = []; x[NaN] = 1; x[0] === undefined. Actual: ' + (x[0]));  \n} \n\n//CHECK#2\nif (x[\"NaN\"] !== 1) {\n  $ERROR('#2: x = []; x[NaN] = 1; x[\"NaN\"] === 1. Actual: ' + (x[\"NaN\"]));  \n} \n\n//CHECK#3\ny = [];\ny[Number.POSITIVE_INFINITY] = 1;\nif (y[0] !== undefined) {\n  $ERROR('#3: y = []; y[Number.POSITIVE_INFINITY] = 1; y[0] === undefined. Actual: ' + (y[0]));  \n}\n\n//CHECK#4\nif (y[\"Infinity\"] !== 1) {\n  $ERROR('#4: y = []; y[Number.POSITIVE_INFINITY] = 1; y[\"Infinity\"] === 1. Actual: ' + (y[\"Infinity\"]));  \n} \n\n//CHECK#5\nz = [];\nz[Number.NEGATIVE_INFINITY] = 1;\nif (z[0] !== undefined) {\n  $ERROR('#5: z = []; z[Number.NEGATIVE_INFINITY] = 1; z[0] === undefined. Actual: ' + (z[0]));  \n}\n\n//CHECK#6\nif (z[\"-Infinity\"] !== 1) {\n  $ERROR('#6: z = []; z[Number.NEGATIVE_INFINITY] = 1; z[\"-Infinity\"] === 1. Actual: ' + (z[\"-Infinity\"]));  \n} \n\n",
    "id": "S15.4_A1.1_T2"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for number primitive",
    "test": "//CHECK#1\nx = [];\nx[4294967296] = 1;\nif (x[0] !== undefined) {\n  $ERROR('#1: x = []; x[4294967296] = 1; x[0] === undefined. Actual: ' + (x[0]));  \n}\n\n//CHECK#2\nif (x[\"4294967296\"] !== 1) {\n  $ERROR('#2: x = []; x[4294967296] = 1; x[\"4294967296\"] === 1. Actual: ' + (x[\"4294967296\"]));  \n}\n\n//CHECK#3\ny = [];\ny[4294967297] = 1;\nif (y[1] !== undefined) {\n  $ERROR('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1]));  \n} \n\n//CHECK#4\nif (y[\"4294967297\"] !== 1) {\n  $ERROR('#4: y = []; y[4294967297] = 1; y[\"4294967297\"] === 1. Actual: ' + (y[\"4294967297\"]));  \n}\n\n//CHECK#5\nz = [];\nz[1.1] = 1;\nif (z[1] !== undefined) {\n  $ERROR('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1]));  \n}\n\n//CHECK#6\nif (z[\"1.1\"] !== 1) {\n  $ERROR('#6: z = []; z[1.1] = 1; z[\"1.1\"] === 1. Actual: ' + (z[\"1.1\"]));  \n}  \n",
    "id": "S15.4_A1.1_T3"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for string primitive",
    "test": "//CHECK#1\nx = [];\nx[\"0\"] = 0;\nif (x[0] !== 0) {\n  $ERROR('#1: x = []; x[\"0\"] = 0; x[0] === 0. Actual: ' + (x[0]));  \n} \n\n//CHECK#2\ny = [];\ny[\"1\"] = 1;\nif (y[1] !== 1) {\n  $ERROR('#2: y = []; y[\"1\"] = 1; y[1] === 1. Actual: ' + (y[1]));  \n}\n\n",
    "id": "S15.4_A1.1_T4"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for null and undefined",
    "test": "//CHECK#1\nx = [];\nx[null] = 0;\nif (x[0] !== undefined) {\n  $ERROR('#1: x = []; x[null] = 1; x[0] === undefined. Actual: ' + (x[0]));  \n}\n\n//CHECK#2\nif (x[\"null\"] !== 0) {\n  $ERROR('#2: x = []; x[null] = 1; x[\"null\"] === 0. Actual: ' + (x[\"null\"]));  \n}\n\n//CHECK#3\ny = [];\ny[undefined] = 0;\nif (y[0] !== undefined) {\n  $ERROR('#3: y = []; y[undefined] = 0; y[0] === undefined. Actual: ' + (y[0]));  \n}\n\n//CHECK#4\nif (y[\"undefined\"] !== 0) {\n  $ERROR('#4: y = []; y[undefined] = 1; y[\"undefined\"] === 0. Actual: ' + (y[\"undefined\"]));  \n}\n",
    "id": "S15.4_A1.1_T5"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for Boolean object",
    "test": "//CHECK#1\nx = [];\nx[new Boolean(true)] = 1;\nif (x[1] !== undefined) {\n  $ERROR('#1: x = []; x[new Boolean(true)] = 1; x[1] === undefined. Actual: ' + (x[1]));  \n}\n\n//CHECK#2\nif (x[\"true\"] !== 1) {\n  $ERROR('#2: x = []; x[true] = 1; x[\"true\"] === 1. Actual: ' + (x[\"true\"]));  \n}\n\n//CHECK#3\nx[new Boolean(false)] = 0;\nif (x[0] !== undefined) {\n  $ERROR('#3: x = []; x[true] = 1; x[new Boolean(false)] = 0; x[0] === undefined. Actual: ' + (x[0]));  \n}\n\n//CHECK#4\nif (x[\"false\"] !== 0) {\n  $ERROR('#4: x = []; x[false] = 1; x[\"false\"] === 0. Actual: ' + (x[\"false\"]));  \n}\n\n",
    "id": "S15.4_A1.1_T6"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for Number object",
    "test": "//CHECK#1\nx = [];\nx[new Number(0)] = 0;\nif (x[0] !== 0) {\n  $ERROR('#1: x = []; x[new Number(0)] = 0; x[0] === 0. Actual: ' + (x[0]));  \n} \n\n//CHECK#2\ny = [];\ny[new Number(1)] = 1;\nif (y[1] !== 1) {\n  $ERROR('#2: y = []; y[new Number(1)] = 1; y[1] === 1. Actual: ' + (y[1]));  \n}\n\n//CHECK#3\nz = [];\nz[new Number(1.1)] = 1;\nif (z[\"1.1\"] !== 1) {\n  $ERROR('#3: z = []; z[new Number(1.1)] = 1; z[\"1.1\"] === 1. Actual: ' + (z[\"1.1\"]));  \n}  \n",
    "id": "S15.4_A1.1_T7"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "Checking for Number object",
    "test": "//CHECK#1\nx = [];\nx[new String(\"0\")] = 0;\nif (x[0] !== 0) {\n  $ERROR('#1: x = []; x[new String(\"0\")] = 0; x[0] === 0. Actual: ' + (x[0]));  \n} \n\n//CHECK#2\ny = [];\ny[new String(\"1\")] = 1;\nif (y[1] !== 1) {\n  $ERROR('#2: y = []; y[new String(\"1\")] = 1; y[1] === 1. Actual: ' + (y[1]));  \n}\n\n//CHECK#3\nz = [];\nz[new String(\"1.1\")] = 1;\nif (z[\"1.1\"] !== 1) {\n  $ERROR('#3: z = []; z[new String(\"1.1\")] = 1; z[\"1.1\"] === 1. Actual: ' + (z[\"1.1\"]));  \n}  \n",
    "id": "S15.4_A1.1_T8"
   },
   {
    "section": "15.4, 11.2.1",
    "description": "If Type(value) is Object, evaluate ToPrimitive(value, String)",
    "test": "//CHECK#1\nx = [];\nvar object = {valueOf: function() {return 1}};\nx[object] = 0;\nif (x[\"[object Object]\"] !== 0) {\n  $ERROR('#1: x = []; var object = {valueOf: function() {return 1}}; x[object] = 0; x[\"[object Object]\"] === 0. Actual: ' + (x[\"[object Object]\"]));\n}\n\n//CHECK#2\nx = [];\nvar object = {valueOf: function() {return 1}, toString: function() {return 0}};\nx[object] = 0;\nif (x[0] !== 0) {\n  $ERROR('#2: x = []; var object = {valueOf: function() {return 1}, toString: function() {return 0}}; x[object] = 0; x[0] === 0. Actual: ' + (x[0]));\n} \n\n//CHECK#3\nx = [];\nvar object = {valueOf: function() {return 1}, toString: function() {return {}}};\nx[object] = 0;\nif (x[1] !== 0) {\n  $ERROR('#3: x = []; var object = {valueOf: function() {return 1}, toString: function() {return {}}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));\n}\n\n//CHECK#4\ntry {\n  x = [];  \n  var object = {valueOf: function() {throw \"error\"}, toString: function() {return 1}};\n  x[object] = 0;\n  if (x[1] !== 0) {\n    $ERROR('#4.1: x = []; var object = {valueOf: function() {throw \"error\"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (x[1]));\n  }\n}\ncatch (e) {\n  if (e === \"error\") {\n    $ERROR('#4.2: x = []; var object = {valueOf: function() {throw \"error\"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (\"error\"));\n  } else {\n    $ERROR('#4.3: x = []; var object = {valueOf: function() {throw \"error\"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (e));\n  }\n}\n\n//CHECK#5\nx = [];\nvar object = {toString: function() {return 1}};\nx[object] = 0;\nif (x[1] !== 0) {\n  $ERROR('#5: x = []; var object = {toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));\n}\n\n//CHECK#6\nx = [];\nvar object = {valueOf: function() {return {}}, toString: function() {return 1}}\nx[object] = 0;\nif (x[1] !== 0) {\n  $ERROR('#6: x = []; var object = {valueOf: function() {return {}}, toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));\n}\n\n//CHECK#7\ntry {\n  x = [];\n  var object = {valueOf: function() {return 1}, toString: function() {throw \"error\"}};\n  x[object];  \n  $ERROR('#7.1: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw \"error\"}}; x[object] throw \"error\". Actual: ' + (x[object]));\n}  \ncatch (e) {\n  if (e !== \"error\") {\n    $ERROR('#7.2: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw \"error\"}}; x[object] throw \"error\". Actual: ' + (e));\n  } \n}\n\n//CHECK#8\ntry {\n  x = [];\n  var object = {valueOf: function() {return {}}, toString: function() {return {}}};\n  x[object];\n  $ERROR('#8.1: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (x[object]));\n}  \ncatch (e) {\n  if ((e instanceof TypeError) !== true) {\n    $ERROR('#8.2: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (e));\n  } \n}  \n",
    "id": "S15.4_A1.1_T9"
   }
  ]
 }
}