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
|
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.toSpliced
description: >
Array.prototype.toSpliced limits the length to 2 ** 32 - 1
info: |
Array.prototype.toSpliced ( start, deleteCount, ...items )
...
3. Let len be ? LengthOfArrayLike(O).
...
11. Let newLen be len + insertCount - actualDeleteCount.
12. If _newLen_ > 2 ** 53< - 1, throw a *TypeError* exception.
13. Let A be ? ArrayCreate(𝔽(newLen)).
...
ArrayCreate ( length [, proto ] )
1. If length > 2 ** 32 - 1, throw a RangeError exception.
features: [change-array-by-copy, exponentiation]
---*/
// Object with large "length" property
var arrayLike = {
get "0"() {
throw new Test262Error("Get 0");
},
get "4294967295" () { // 2 ** 32 - 1
throw new Test262Error("Get 4294967295");
},
get "4294967296" () { // 2 ** 32
throw new Test262Error("Get 4294967296");
},
length: 2 ** 32
};
assert.throws(RangeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0);
});
arrayLike.length = 2 ** 32 - 1;
assert.throws(RangeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 32;
assert.throws(RangeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 32 + 1;
assert.throws(RangeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 52 - 2;
assert.throws(RangeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 53 - 1;
assert.throws(TypeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 53;
assert.throws(TypeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
arrayLike.length = 2 ** 53 + 1;
assert.throws(TypeError, function() {
Array.prototype.toSpliced.call(arrayLike, 0, 0, 1);
});
reportCompare(0, 0);
|