aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.4.1_The_Array_Constructor_Called_as_a_Function.json
blob: 9c72ec09e6af523c38fa3cfdb9e449391c9882db (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
{
 "testCollection": {
  "name": "15.4.1_The_Array_Constructor_Called_as_a_Function",
  "numTests": 8,
  "tests": [
   {
    "section": "15.4.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 = Array(); \nif (x.myproperty !== 1) {\n  $ERROR('#1: Array.prototype.myproperty = 1; var x = 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 = Array(); x.hasOwnProperty(\\'myproperty\\') === false. Actual: ' + (x.hasOwnProperty('myproperty')));\n}\n",
    "id": "S15.4.1_A1.1_T1"
   },
   {
    "section": "15.4.1, 15.2.4.2",
    "description": "Array.prototype.toString = Object.prototype.toString",
    "test": "//CHECK#1\nArray.prototype.toString = Object.prototype.toString;\nvar x = Array(); \nif (x.toString() !== \"[object \" + \"Array\" + \"]\") {\n  $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = Array(); x.toString() === \"[object \" + \"Array\" + \"]\". Actual: ' + (x.toString()));\n}\n\n//CHECK#2\nArray.prototype.toString = Object.prototype.toString;\nvar x = Array(0,1,2); \nif (x.toString() !== \"[object \" + \"Array\" + \"]\") {\n  $ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = Array(0,1,2); x.toString() === \"[object \" + \"Array\" + \"]\". Actual: ' + (x.toString()));\n}\n\n",
    "id": "S15.4.1_A1.1_T2"
   },
   {
    "section": "15.4.1, 15.2.4.6",
    "description": "Checking use isPrototypeOf",
    "test": "//CHECK#1\nif (Array.prototype.isPrototypeOf(Array()) !== true) {\n  $ERROR('#1: Array.prototype.isPrototypeOf(Array()) === true. Actual: ' + (Array.prototype.isPrototypeOf(Array())));\n}\n\n",
    "id": "S15.4.1_A1.1_T3"
   },
   {
    "section": "15.4.1, 15.2.4.2",
    "description": "Checking use Object.prototype.toString",
    "test": "//CHECK#1\nvar x = Array(); \nx.getClass = Object.prototype.toString;\nif (x.getClass() !== \"[object \" + \"Array\" + \"]\") {\n  $ERROR('#1: var x = Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));\n}\n\n//CHECK#2\nvar x = Array(0,1,2); \nx.getClass = Object.prototype.toString;\nif (x.getClass() !== \"[object \" + \"Array\" + \"]\") {\n  $ERROR('#2: var x = Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));\n}\n",
    "id": "S15.4.1_A1.2_T1"
   },
   {
    "section": "15.4.1",
    "description": "Checking case when Array constructor is given one argument",
    "test": "var x = Array(2);\n\n//CHECK#1\nif (x.length === 1) {\n  $ERROR('#1: var x = Array(2); x.length !== 1');\n}\n\n//CHECK#2\nif (x[0] === 2) {\n  $ERROR('#2: var x = Array(2); x[0] !== 2');\n}\n",
    "id": "S15.4.1_A1.3_T1"
   },
   {
    "section": "15.4.1",
    "description": "Array constructor is given no arguments or at least two arguments",
    "test": "//CHECK#1\nif (Array().length !== 0) {\n  $ERROR('#1: (Array().length === 0. Actual: ' + (Array().length));\n}\n\n//CHECK#2\nif (Array(0,1,0,1).length !== 4) {\n  $ERROR('#2: (Array(0,1,0,1).length === 4. Actual: ' + (Array(0,1,0,1).length));\n}\n\n//CHECK#3\nif (Array(undefined, undefined).length !== 2) {\n  $ERROR('#3: (Array(undefined, undefined).length === 2. Actual: ' + (Array(undefined, undefined).length));\n}\n",
    "id": "S15.4.1_A2.1_T1"
   },
   {
    "section": "15.4.1",
    "description": "Checking correct work this algorithm",
    "test": "//CHECK#\nvar x = 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.1_A2.2_T1"
   },
   {
    "section": "15.4.1, 11.4.3, 11.8.6",
    "description": "Checking use typeof, instanceof",
    "test": "//CHECK#1\nif (typeof Array() !== \"object\") {\n  $ERROR('#1: typeof Array() === \"object\". Actual: ' + (typeof Array()));\n}  \n\n//CHECK#2\nif ((Array() instanceof Array) !== true) {\n  $ERROR('#2: (Array() instanceof Array) === true. Actual: ' + (Array() instanceof Array));\n}  \n",
    "id": "S15.4.1_A3.1_T1"
   }
  ]
 }
}