mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Add coverage for throw completions in (Typed)Array.prototype.with
SpiderMonkey doesn't handle this correctly for `Array.prototype.with`.
This commit is contained in:
parent
006b3046fa
commit
8649d5e117
27
test/built-ins/Array/prototype/with/index-throw-completion.js
vendored
Normal file
27
test/built-ins/Array/prototype/with/index-throw-completion.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.with
|
||||||
|
description: >
|
||||||
|
Index coercion returns a throw completion.
|
||||||
|
info: |
|
||||||
|
Array.prototype.with ( index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||||
|
...
|
||||||
|
features: [change-array-by-copy]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function MyError() {}
|
||||||
|
|
||||||
|
var index = {
|
||||||
|
valueOf() {
|
||||||
|
throw new MyError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(MyError, function() {
|
||||||
|
[].with(index, null);
|
||||||
|
});
|
38
test/built-ins/TypedArray/prototype/with/index-throw-completion.js
vendored
Normal file
38
test/built-ins/TypedArray/prototype/with/index-throw-completion.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.with
|
||||||
|
description: >
|
||||||
|
Index coercion returns a throw completion.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.with ( index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||||
|
...
|
||||||
|
features: [TypedArray, change-array-by-copy]
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function MyError() {}
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var ta = new TA(1);
|
||||||
|
|
||||||
|
var index = {
|
||||||
|
valueOf() {
|
||||||
|
throw new MyError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var value = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error("Unexpected value coercion");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(MyError, function() {
|
||||||
|
ta.with(index, value);
|
||||||
|
});
|
||||||
|
});
|
37
test/built-ins/TypedArray/prototype/with/value-throw-completion.js
vendored
Normal file
37
test/built-ins/TypedArray/prototype/with/value-throw-completion.js
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.with
|
||||||
|
description: >
|
||||||
|
Value coercion returns a throw completion.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.with ( index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
7. If O.[[ContentType]] is bigint, let numericValue be ? ToBigInt(value).
|
||||||
|
8. Else, let numericValue be ? ToNumber(value).
|
||||||
|
...
|
||||||
|
features: [TypedArray, change-array-by-copy]
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function MyError() {}
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var ta = new TA(1);
|
||||||
|
|
||||||
|
var value = {
|
||||||
|
valueOf() {
|
||||||
|
throw new MyError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(MyError, function() {
|
||||||
|
ta.with(100, value);
|
||||||
|
}, "Positive too large index");
|
||||||
|
|
||||||
|
assert.throws(MyError, function() {
|
||||||
|
ta.with(-100, value);
|
||||||
|
}, "Negative too large index");
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user