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
|
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-properties-of-the-array-prototype-object
description: >
Array.prototype methods resolve `this` value using strict mode semantics,
throwing TypeError if called as top-level function.
info: |
Array.prototype.concat ( ...items )
1. Let O be ? ToObject(this value).
ToObject ( argument )
Argument Type: Undefined
Result: Throw a TypeError exception.
features: [Symbol, Symbol.isConcatSpreadable, Symbol.iterator, Symbol.species, Array.prototype.flat, Array.prototype.flatMap, Array.prototype.includes]
---*/
["constructor", "length", "0", Symbol.isConcatSpreadable, Symbol.species].forEach(function(key) {
Object.defineProperty(this, key, {
get: function() {
throw new Test262Error(String(key) + " lookup should not be performed");
},
});
}, this);
function callback() {
throw new Test262Error("callback should not be called");
}
var index = {
get valueOf() {
throw new Test262Error("index should not be coerced to number");
},
};
var separator = {
get toString() {
throw new Test262Error("separator should not be coerced to string");
},
};
var concat = Array.prototype.concat;
assert.throws(TypeError, function() {
concat();
}, "concat");
var copyWithin = Array.prototype.copyWithin;
assert.throws(TypeError, function() {
copyWithin(index, index);
}, "copyWithin");
var entries = Array.prototype.entries;
assert.throws(TypeError, function() {
entries();
}, "entries");
var every = Array.prototype.every;
assert.throws(TypeError, function() {
every(callback);
}, "every");
var fill = Array.prototype.fill;
assert.throws(TypeError, function() {
fill(0);
}, "fill");
var filter = Array.prototype.filter;
assert.throws(TypeError, function() {
filter(callback);
}, "filter");
var find = Array.prototype.find;
assert.throws(TypeError, function() {
find(callback);
}, "find");
var findIndex = Array.prototype.findIndex;
assert.throws(TypeError, function() {
findIndex(callback);
}, "findIndex");
var flat = Array.prototype.flat;
assert.throws(TypeError, function() {
flat(index);
}, "flat");
var flatMap = Array.prototype.flatMap;
assert.throws(TypeError, function() {
flatMap(callback);
}, "flatMap");
var forEach = Array.prototype.forEach;
assert.throws(TypeError, function() {
forEach(callback);
}, "forEach");
var includes = Array.prototype.includes;
assert.throws(TypeError, function() {
includes(0, index);
}, "includes");
var indexOf = Array.prototype.indexOf;
assert.throws(TypeError, function() {
indexOf(0, index);
}, "indexOf");
var join = Array.prototype.join;
assert.throws(TypeError, function() {
join(separator);
}, "join");
var keys = Array.prototype.keys;
assert.throws(TypeError, function() {
keys();
}, "keys");
var lastIndexOf = Array.prototype.lastIndexOf;
assert.throws(TypeError, function() {
lastIndexOf(0, index);
}, "lastIndexOf");
var map = Array.prototype.map;
assert.throws(TypeError, function() {
map(callback);
}, "map");
var pop = Array.prototype.pop;
assert.throws(TypeError, function() {
pop();
}, "pop");
var push = Array.prototype.push;
assert.throws(TypeError, function() {
push();
}, "push");
var reduce = Array.prototype.reduce;
assert.throws(TypeError, function() {
reduce(callback, 0);
}, "reduce");
var reduceRight = Array.prototype.reduceRight;
assert.throws(TypeError, function() {
reduceRight(callback, 0);
}, "reduceRight");
var reverse = Array.prototype.reverse;
assert.throws(TypeError, function() {
reverse();
}, "reverse");
var shift = Array.prototype.shift;
assert.throws(TypeError, function() {
shift();
}, "shift");
var slice = Array.prototype.slice;
assert.throws(TypeError, function() {
slice(index, index);
}, "slice");
var some = Array.prototype.some;
assert.throws(TypeError, function() {
some(callback);
}, "some");
var sort = Array.prototype.sort;
assert.throws(TypeError, function() {
sort(callback);
}, "sort");
var splice = Array.prototype.splice;
assert.throws(TypeError, function() {
splice(index, index);
}, "splice");
var toLocaleString = Array.prototype.toLocaleString;
assert.throws(TypeError, function() {
toLocaleString();
}, "toLocaleString");
var toString = Array.prototype.toString;
assert.throws(TypeError, function() {
toString();
}, "toString");
var unshift = Array.prototype.unshift;
assert.throws(TypeError, function() {
unshift();
}, "unshift");
var values = Array.prototype.values;
assert.throws(TypeError, function() {
values();
}, "values");
var iterator = Array.prototype[Symbol.iterator];
assert.throws(TypeError, function() {
iterator();
}, "Symbol.iterator");
reportCompare(0, 0);
|