Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to cover new TA::with behavior #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ esid: sec-array.prototype.toReversed
description: >
Array.prototype.toReversed works on frozen objects
features: [change-array-by-copy]
includes: [compareArray.js]
---*/

var arr = Object.freeze([0, 1, 2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSorted
description: >
Array.prototype.toSorted works on frozen objects
features: [change-array-by-copy]
includes: [compareArray.js]
---*/

var arr = Object.freeze([2, 0, 1]);
Expand Down
31 changes: 31 additions & 0 deletions test/built-ins/TypedArray/prototype/with/early-type-coercion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2021 Igalia. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-%typedarray%.prototype.with
description: >
%TypedArray%.prototype.with invokes ToNumber before copying
info: |
%TypedArray%.prototype.with ( index, value )

...
7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_).
8. Else, set _value_ to ? ToNumber(_value_).
...
features: [TypedArray, change-array-by-copy]
includes: [testTypedArray.js, compareArray.js]
---*/

testWithTypedArrayConstructors(TA => {
var arr = new TA([0, 1, 2]);

var value = {
valueOf() {
arr[0] = 3;
return 4;
}
};

assert.compareArray(arr.with(1, value), [3, 4, 2]);
assert.compareArray(arr, [3, 1, 2]);
});