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
|
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.slice
description: >
Length property is clamped to 2^53-1, test with indices near 2^53-1 and negative indices.
info: |
...
2. Let len be ? ToLength(? Get(O, "length")).
3. Let relativeStart be ? ToInteger(start).
4. If relativeStart < 0, let k be max((len + relativeStart), 0);
else let k be min(relativeStart, len).
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
6. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
else let final be min(relativeEnd, len).
...
includes: [compareArray.js]
---*/
var arrayLike = {
"9007199254740988": "9007199254740988",
"9007199254740989": "9007199254740989",
"9007199254740990": "9007199254740990",
"9007199254740991": "9007199254740991",
length: 2 ** 53 + 2,
};
var result = Array.prototype.slice.call(arrayLike, 9007199254740989);
assert.compareArray(result, ["9007199254740989", "9007199254740990"],
"slice(9007199254740989)");
var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740990);
assert.compareArray(result, ["9007199254740989"],
"slice(9007199254740989, 9007199254740990)");
var result = Array.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740996);
assert.compareArray(result, ["9007199254740989", "9007199254740990"],
"slice(9007199254740989, 9007199254740996)");
var result = Array.prototype.slice.call(arrayLike, -2);
assert.compareArray(result, ["9007199254740989", "9007199254740990"],
"slice(-2)");
var result = Array.prototype.slice.call(arrayLike, -2, -1);
assert.compareArray(result, ["9007199254740989"],
"slice(-2, -1)");
|