summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js94
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js94
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js97
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js113
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js95
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js75
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js47
26 files changed, 1545 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js
new file mode 100644
index 0000000000..81c4a3a943
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ end argument is coerced to an integer values.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true),
+ [0n, 0n, 2n, 3n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'),
+ [0n, 0n, 1n, 3n]
+ ),
+ 'string "-2" value coerced to integer -2'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5),
+ [0n, 0n, 1n, 3n]
+ ),
+ 'float -2.5 value coerced to integer -2'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js
new file mode 100644
index 0000000000..278e95b791
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js
@@ -0,0 +1,94 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ start argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, false),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, null),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, true),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5),
+ [0n, 0n, 1n, 2n]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5),
+ [1n, 2n, 3n, 3n]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js
new file mode 100644
index 0000000000..a5556c519a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js
@@ -0,0 +1,94 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ target argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..f017576090
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.copyWithin(obj, obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..f9e3b903d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA();
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.sameValue(sample.copyWithin(0, 0), sample);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js
new file mode 100644
index 0000000000..f1fde574bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js
@@ -0,0 +1,97 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1),
+ [1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1),
+ [0n, 1n, 0n, 1n, 2n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2),
+ [0n, 2n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1),
+ [2n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1),
+ [0n, 1n, 3n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1),
+ [0n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1),
+ [3n, 1n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..55710a2447
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js
@@ -0,0 +1,113 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative out of bounds end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js
new file mode 100644
index 0000000000..997436c7bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10),
+ [0n, 1n, 0n, 1n, 2n]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity),
+ [1n, 2n, 1n, 2n, 3n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10),
+ [0n, 1n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js
new file mode 100644
index 0000000000..925be0ce7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2),
+ [2n, 3n, 4n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2),
+ [3n, 4n, 5n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js
new file mode 100644
index 0000000000..d7ac9c82b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1),
+ [3n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2),
+ [0n, 1n, 3n, 4n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2),
+ [0n, 3n, 4n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2),
+ [0n, 1n, 2n, 2n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2),
+ [3n, 4n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js
new file mode 100644
index 0000000000..286910f628
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0),
+ [0n, 1n, 2n, 0n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2),
+ [0n, 1n, 2n, 2n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..45440750fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max value of end position is the this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity),
+ [2n, 3n, 4n, 5n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6),
+ [0n, 3n, 4n, 5n, 4n, 5n]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity),
+ [1n, 4n, 5n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js
new file mode 100644
index 0000000000..51f22654a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max values of target and start positions are this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js
new file mode 100644
index 0000000000..137f9190cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target and start positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0),
+ [1n, 2n, 3n, 4n, 5n, 6n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2),
+ [3n, 4n, 5n, 6n, 5n, 6n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0),
+ [1n, 2n, 3n, 1n, 2n, 3n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4),
+ [0n, 4n, 5n, 3n, 4n, 5n]
+ )
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js
new file mode 100644
index 0000000000..17ddf9d1c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js
@@ -0,0 +1,75 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target, start and end positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2),
+ [1n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
+ );
+
+ /*
+ * 10. If from<to and to<from+count, then
+ * a. Let direction be - 1.
+ * b. Let from be from + count - 1.
+ * c. Let to be to + count - 1.
+ *
+ * 0 < 1, 1 < 0 + 2
+ * direction = -1
+ * from = 0 + 2 - 1
+ * to = 1 + 2 - 1
+ */
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2),
+ [0n, 0n, 1n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5),
+ [0n, 3n, 4n, 3n, 4n, 5n]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js
new file mode 100644
index 0000000000..1aa2fb1f99
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if end is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, 0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js
new file mode 100644
index 0000000000..a2cc76eb35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(end).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, 0, o1);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js
new file mode 100644
index 0000000000..2a49db8598
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if start is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js
new file mode 100644
index 0000000000..b7a03a0ea1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(start).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var err = {
+ valueOf: function() {
+ throw new Error("ToInteger(start) runs before ToInteger(end)");
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, o, err);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js
new file mode 100644
index 0000000000..51851b1bfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if target is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(s, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js
new file mode 100644
index 0000000000..d80ca93e1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(target).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(o);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..871cbbf873
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.copyWithin,
+ 'function',
+ 'implements TypedArray.prototype.copyWithin'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.copyWithin(0, 0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.copyWithin(0, 0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the copyWithin operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.copyWithin(0, 0);
+ throw new Test262Error('copyWithin completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js
new file mode 100644
index 0000000000..b67372010b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Returns `this`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 13. Return O.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.copyWithin(0, 0);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA([1n, 2n, 3n]);
+ var result2 = sample2.copyWithin(1, 0);
+
+ assert.sameValue(result2, sample2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of BigInt TypedArray objects.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js
new file mode 100644
index 0000000000..ea081c6ef3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ If `end` is undefined, set final position to `this.length`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
+ );
+});
+
+reportCompare(0, 0);