aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.3.5_Properties_of_Function_Instances.json
blob: a2278ed188cdbc300e40aec2b3f0058d5571959d (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
 "testCollection": {
  "name": "15.3.5_Properties_of_Function_Instances",
  "numTests": 33,
  "tests": [
   {
    "section": "15.3.5.1",
    "description": "Checking length property of Function(\"arg1,arg2,arg3\", null)",
    "test": "f = new Function(\"arg1,arg2,arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\n//CHECK#2\nif (f.length !== 3) {\n  $ERROR('#2: The value of the length property is usually an integer that indicates the \"typical\" number of arguments expected by the function');\n}\n",
    "id": "S15.3.5.1_A1_T1"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking length property of Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null)",
    "test": "f = Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\n//CHECK#2\nif (f.length !== 5) {\n  $ERROR('#2: The value of the length property is usually an integer that indicates the \"typical\" number of arguments expected by the function');\n}\n",
    "id": "S15.3.5.1_A1_T2"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking length property of Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null)",
    "test": "f = new Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\n//CHECK#2\nif (f.length !== 6) {\n  $ERROR('#2: The value of the length property is usually an integer that indicates the \"typical\" number of arguments expected by the function');\n}\n",
    "id": "S15.3.5.1_A1_T3"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if deleting the length property of Function(\"arg1,arg2,arg3\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\n//CHECK#2\nif(delete f.length){\n  $ERROR('#2: the function.length property has the attributes DontDelete.');\n}\n\n//CHECK#3\nif (!(f.hasOwnProperty('length'))) {\n  $ERROR('#3: the function.length property has the attributes DontDelete.');\n}\n\n//CHECK#4\nif (f.length !== 3) {\n  $ERROR('#4: the length property has the attributes { DontDelete }');\n}\n",
    "id": "S15.3.5.1_A2_T1"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if deleting the length property of Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null) fails",
    "test": "f =  Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\ndelete f.length;\n\n//CHECK#2\nif (!(f.hasOwnProperty('length'))) {\n  $ERROR('#2: the function.length property has the attributes DontDelete.');\n}\n\n//CHECK#3\nif (f.length !== 5) {\n  $ERROR('#3: the length property has the attributes { DontDelete }');\n}\n",
    "id": "S15.3.5.1_A2_T2"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if deleting the length property of Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\ndelete f.length;\n\n//CHECK#2\nif (!(f.hasOwnProperty('length'))) {\n  $ERROR('#2: the function.length property has the attributes DontDelete.');\n}\n\n//CHECK#3\nif (f.length !== 6) {\n  $ERROR('#3: the length property has the attributes { DontDelete }');\n}\n",
    "id": "S15.3.5.1_A2_T3"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if varying the length property of Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nlength = f.length;\n\nf.length = function(){};\n\n//CHECK#2\nif (f.length !== length) {\n  $ERROR('#2: the function.length property has the attributes ReadOnly');\n}\n\n//CHECK#3\ntry {\n  f.length();\n  $ERROR('#3: the function.length property has the attributes ReadOnly');\n} catch (e) {\n  ;\n}\n\n//CHECK#4\nif (f.length !== 5) {\n  $ERROR('#4: the length property has the attributes { ReadOnly }');\n}\n",
    "id": "S15.3.5.1_A3_T1"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if varying the length property of Function(\"arg1,arg2,arg3\", null) fails",
    "test": "f =  Function(\"arg1,arg2,arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nlength = f.length;\n\nf.length = function(){};\n\n//CHECK#2\nif (f.length !== length) {\n  $ERROR('#2: the function.length property has the attributes ReadOnly');\n}\n\n//CHECK#3\ntry {\n  f.length();\n  $ERROR('#3: the function.length property has the attributes ReadOnly');\n} catch (e) {\n  ;\n}\n\n//CHECK#4\nif (f.length !== 3) {\n  $ERROR('#4: the length property has the attributes { ReadOnly }');\n}\n",
    "id": "S15.3.5.1_A3_T2"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if varying the length property of Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nlength = f.length;\n\nf.length = function(){};\n\n//CHECK#2\nif (f.length !== length) {\n  $ERROR('#2: the function.length property has the attributes ReadOnly');\n}\n\n//CHECK#3\ntry {\n  f.length();\n  $ERROR('#3: the function.length property has the attributes ReadOnly');\n} catch (e) {\n  ;\n}\n\n//CHECK#4\nif (f.length !== 6) {\n  $ERROR('#4: the length property has the attributes { ReadOnly }');\n}\n",
    "id": "S15.3.5.1_A3_T3"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if enumerating the length property of Function(\"arg1,arg2,arg3\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nfor(key in f)    \n  if(key==\"length\")\n      var lengthenumed=true;\n      \n//CHECK#2\nif (lengthenumed) {\n  $ERROR('#2: the length property has the attributes { DontEnum }');\n}\n",
    "id": "S15.3.5.1_A4_T1"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if enumerating the length property of Function(\"arg1,arg2,arg3\",\"arg4,arg5\", null) fails",
    "test": "f =  Function(\"arg1,arg2,arg3\",\"arg5,arg4\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nfor(key in f)    \n  if(key==\"length\")\n      var lengthenumed=true;\n      \n//CHECK#2\nif (lengthenumed) {\n  $ERROR('#2: the length property has the attributes { DontEnum }');\n}\n",
    "id": "S15.3.5.1_A4_T2"
   },
   {
    "section": "15.3.5.1",
    "description": "Checking if enumerating the length property of Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null) fails",
    "test": "f = new Function(\"arg1,arg2,arg3\",\"arg1,arg2\",\"arg3\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('length'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nfor(key in f)    \n  if(key==\"length\")\n    var lengthenumed=true;\n      \n//CHECK#2\nif (lengthenumed) {\n  $ERROR('#2: the length property has the attributes { DontEnum }');\n}\n",
    "id": "S15.3.5.1_A4_T3"
   },
   {
    "section": "15.3.5.2",
    "description": "Checking if deleting the prototype property of Function(\"\", null) fails",
    "test": "f = new Function(\"\", null);\n\n//CHECK#1\nif (!(f.hasOwnProperty('prototype'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nfproto = f.prototype;\n\n//CHECK#2\nif (delete f.prototype) {\n  $ERROR('#2: the prototype property has the attributes { DontDelete }');\n}\n\n//CHECK#3\nif (f.prototype !== fproto) {\n  $ERROR('#3: the prototype property has the attributes { DontDelete }');\n}\n",
    "id": "S15.3.5.2_A1_T1"
   },
   {
    "section": "15.3.5.2",
    "description": "Checking if deleting the prototype property of Function(void 0, \"\") fails",
    "test": "f = Function(void 0, \"\");\n\n//CHECK#1\nif (!(f.hasOwnProperty('prototype'))) {\n  $FAIL('#1: the function has length property.');\n}\n\nfproto = f.prototype;\n\n//CHECK#2\nif (delete f.prototype) {\n  $ERROR('#2: the prototype property has the attributes { DontDelete }');\n}\n\n//CHECK#3\nif (f.prototype !== fproto) {\n  $ERROR('#3: the prototype property has the attributes { DontDelete }');\n}\n",
    "id": "S15.3.5.2_A1_T2"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is number",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((1 instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T1"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is string",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((\"1\" instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T2"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is boolean true",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((true instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T3"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is boolean false",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((false instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T4"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is void 0",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((void 0 instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T5"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is null",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((null instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T6"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is undefined",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((undefined instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n",
    "id": "S15.3.5.3_A1_T7"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "V is undefined variable",
    "test": "FACTORY = Function(\"name\",\"this.name=name;\");\n\n//CHECK#1\nif ((x instanceof  FACTORY)!==false) {\n  $ERROR('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');\n}\n\nvar x;\n",
    "id": "S15.3.5.3_A1_T8"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "F.prototype is undefined, and V is empty object",
    "test": "FACTORY = new Function;\n\nFACTORY.prototype = undefined;\n\nobj={};\n\n//CHECK#1\ntry {\n  obj instanceof  FACTORY;\n  $FAIL('#1: O is not an object, throw a TypeError exception');\n} catch (e) {\n  if (!(e instanceof TypeError)) {\n  \t$ERROR('#1.1: O is not an object, throw a TypeError exception');\n  }\n}\n\n\n",
    "id": "S15.3.5.3_A2_T2"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "F.prototype is void 0, and V is new F",
    "test": "FACTORY = Function(\"this.prop=1;\");\n\nFACTORY.prototype.name = \"fairy\";\n\ninstance = new FACTORY;\n\nFACTORY.prototype = void 0;\n\n// CHECK#1\ntry {\n  instance instanceof FACTORY;\n  $FAIL('#1: O is not an object, throw a TypeError exception');\n} catch (e) {\n  if (!(e instanceof TypeError)) {\n    $ERROR('#1.1: O is not an object, throw a TypeError exception');\n  }\n}\n\n// CHECK#2\nif ((instance.constructor !== FACTORY) || (instance.name !== \"fairy\")) {\n  $ERROR('#2: instance.constructor === FACTORY');\n}\n",
    "id": "S15.3.5.3_A2_T5"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "F.prototype is string, and V is function",
    "test": "FACTORY = new Function;\n\nFACTORY.prototype = \"error\";\n\n// CHECK#1\ntry {\n  ( function() {\n  }) instanceof FACTORY;\n  $FAIL('#1: O is not an object, throw a TypeError exception');\n} catch (e) {\n  if (!(e instanceof TypeError)) {\n    $ERROR('#1.1: O is not an object, throw a TypeError exception');\n  }\n}\n",
    "id": "S15.3.5.3_A2_T6"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "F.prototype.type is 1, and V is new F",
    "test": "FACTORY = Function(\"this.name=\\\"root\\\"\");\n\nFACTORY.prototype.type=1;\n\ninstance = new FACTORY;\n\n//CHECK#1\nif (!(instance instanceof FACTORY)) {\n  $ERROR('#1: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');\n}\n",
    "id": "S15.3.5.3_A3_T1"
   },
   {
    "section": "15.3.5.3, 11.8.6",
    "description": "F.prototype is Object.prototype, and V is empty object",
    "test": "FAKEFACTORY = Function();\n\nfakeinstance = {};\n\n//CHECK#1\nif (fakeinstance instanceof FAKEFACTORY) {\n  $ERROR('#1: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');\n}\n\nFAKEFACTORY.prototype=Object.prototype;\n\n//CHECK#2\nif (!(fakeinstance instanceof FAKEFACTORY)) {\n  $ERROR('#2: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');\n}\n",
    "id": "S15.3.5.3_A3_T2"
   },
   {
    "section": "15.3.5",
    "description": "For testing use variable f = new Function",
    "test": "var f = new Function;\n\nif (Object.prototype.toString.call(f) !== \"[object Function]\") {\n  $ERROR('#1: The value of the [[Class]] property is \"Function\"');\n}\n",
    "id": "S15.3.5_A1_T1"
   },
   {
    "section": "15.3.5",
    "description": "For testing use variable f = Function()",
    "test": "var f = Function();\n\nif (Object.prototype.toString.call(f) !== \"[object Function]\") {\n  $ERROR('#1: The value of the [[Class]] property is \"Function\"');\n}\n\n",
    "id": "S15.3.5_A1_T2"
   },
   {
    "section": "15.3.5",
    "description": ": For testing call Function(\"var x =1; this.y=2;return \\\"OK\\\";\")();",
    "test": "//CHECK#1\nif (Function(\"var x =1; this.y=2;return \\\"OK\\\";\")() !== \"OK\") {\n  $ERROR('#1: Every function instance has a [[Call]] property');\n}\n\n//CHECK#2\nif (typeof x !== \"undefined\") {\n  $ERROR('#2: Every function instance has a [[Call]] property');\n}\n\n//CHECK#3\nif (y !== 2) {\n  $ERROR('#3: Every function instance has a [[Call]] property');\n}\n",
    "id": "S15.3.5_A2_T1"
   },
   {
    "section": "15.3.5",
    "description": ": For testing call (new Function(\"arg1,arg2\",\"var x =arg1; this.y=arg2;return arg1+arg2;\"))(\"1\",2);",
    "test": "//CHECK#1\nif ((new Function(\"arg1,arg2\",\"var x =arg1; this.y=arg2;return arg1+arg2;\"))(\"1\",2) !== \"12\") {\n  $ERROR('#1: Every function instance has a [[Call]] property');\n}\n\n//CHECK#2\nif (typeof x !== \"undefined\") {\n  $ERROR('#2: Every function instance has a [[Call]] property');\n}\n\n//CHECK#3\nif (y !== 2) {\n  $ERROR('#3: Every function instance has a [[Call]] property');\n}\n",
    "id": "S15.3.5_A2_T2"
   },
   {
    "section": "15.3.5",
    "description": ": As constructor use Function(\"var x =1; this.y=2;return \\\"OK\\\";\");",
    "test": "FACTORY = Function(\"var x =1; this.y=2;return \\\"OK\\\";\");\nobj = new FACTORY;\n\n//CHECK#1\nif (typeof obj !== \"object\") {\n  $ERROR('#1: every function instance has a [[Construct]] property');\n}\n\n//CHECK#2\nif (obj.constructor !== FACTORY) {\n  $ERROR('#2: every function instance has a [[Construct]] property');\n}\n\n//CHECK#3\nif (obj.y !== 2) {\n  $ERROR('#3: every function instance has a [[Construct]] property');\n}\n",
    "id": "S15.3.5_A3_T1"
   },
   {
    "section": "15.3.5",
    "description": ": As constructor use new Function(\"arg1,arg2\",\"var x =1; this.y=arg1+arg2;return \\\"OK\\\";\");",
    "test": "FACTORY = new Function(\"arg1,arg2\",\"var x =1; this.y=arg1+arg2;return \\\"OK\\\";\");\nobj = new FACTORY(\"1\",2);\n\n//CHECK#1\nif (typeof obj !== \"object\") {\n  $ERROR('#1: every function instance has a [[Construct]] property');\n}\n\n//CHECK#2\nif (obj.constructor !== FACTORY) {\n  $ERROR('#2: every function instance has a [[Construct]] property');\n}\n\n//CHECK#3\nif (obj.y !== \"12\") {\n  $ERROR('#3: every function instance has a [[Construct]] property');\n}\n",
    "id": "S15.3.5_A3_T2"
   }
  ]
 }
}