blob: 6b36b3dccf63db875db538bbb27c0158e39871c4 (
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
|
// 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.toSorted
description: >
Array.prototype.toSorted doesn't call compareFn if there is an error
info: |
Array.prototype.toSorted ( compareFn )
...
7. Sort items using an implementation-defined sequence of
calls to SortCompare. If any such call returns an abrupt
completion, stop before performing any further calls to
SortCompare or steps in this algorithm and return that completion.
...
features: [change-array-by-copy]
---*/
var arrayLike = {
length: 1,
get 0() { throw new Test262Error(); },
};
var called = false;
assert.throws(Test262Error, function() {
Array.prototype.toSorted.call(arrayLike, () => {
called = true;
});
});
assert.sameValue(called, false);
called = 0;
assert.throws(Test262Error, function() {
[1, 2, 3].toSorted(() => {
++called;
if (called === 1) {
throw new Test262Error();
}
});
});
assert.sameValue(called, 1);
reportCompare(0, 0);
|