summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray
diff options
context:
space:
mode:
authorLeonardo Balter <leonardo.balter@gmail.com>2016-04-12 16:31:37 -0400
committerMike Pennisi <mike@mikepennisi.com>2016-04-20 14:08:33 -0400
commit88f390d189cf59567e91b56e9993b001abcb3bfa (patch)
tree2b27299d9540cb6468e7c8ffe052d32be65b4869 /test/built-ins/TypedArray
parent5e8b661050bf1d4395ad5760813db571f14991c7 (diff)
downloadqtdeclarative-testsuites-88f390d189cf59567e91b56e9993b001abcb3bfa.tar.gz
Add tests for TypedArrays copyWithin
Diffstat (limited to 'test/built-ins/TypedArray')
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js77
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js92
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js92
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js49
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-end.js95
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js71
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js61
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js45
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-start.js77
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/negative-target.js53
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js38
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js50
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js50
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js73
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js37
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js39
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js36
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js45
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js36
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js39
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/return-this.js36
-rw-r--r--test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js45
22 files changed, 1236 insertions, 0 deletions
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js
new file mode 100644
index 000000000..1433d0184
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js
@@ -0,0 +1,77 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, null),
+ [0, 1, 2, 3]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN),
+ [0, 1, 2, 3]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, false),
+ [0, 1, 2, 3]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, true),
+ [0, 0, 2, 3]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'),
+ [0, 0, 1, 3]
+ ),
+ 'string "-2" value coerced to integer -2'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5),
+ [0, 0, 1, 3]
+ ),
+ 'float -2.5 value coerced to integer -2'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js
new file mode 100644
index 000000000..4aba3d7d8
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js
@@ -0,0 +1,92 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, undefined),
+ [0, 0, 1, 2]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, false),
+ [0, 0, 1, 2]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, NaN),
+ [0, 0, 1, 2]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, null),
+ [0, 0, 1, 2]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, true),
+ [1, 2, 3, 3]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, '1'),
+ [1, 2, 3, 3]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0.5),
+ [0, 0, 1, 2]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1.5),
+ [1, 2, 3, 3]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js
new file mode 100644
index 000000000..7a6303036
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js
@@ -0,0 +1,92 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(undefined, 1),
+ [1, 2, 3, 3]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(false, 1),
+ [1, 2, 3, 3]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(NaN, 1),
+ [1, 2, 3, 3]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(null, 1),
+ [1, 2, 3, 3]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(true, 0),
+ [0, 0, 1, 2]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin('1', 0),
+ [0, 0, 1, 2]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0.5, 1),
+ [1, 2, 3, 3]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1.5, 0),
+ [0, 0, 1, 2]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
new file mode 100644
index 000000000..e631b72c7
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
@@ -0,0 +1,49 @@
+// 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
+es6id: 22.2.3.5
+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: [testTypedArray.js]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(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);
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js
new file mode 100644
index 000000000..1260a6a18
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-end.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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, -1),
+ [1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1),
+ [0, 1, 0, 1, 2]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2),
+ [0, 2, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -2, -1),
+ [2, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1),
+ [0, 1, 3, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1),
+ [0, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1),
+ [3, 1, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
new file mode 100644
index 000000000..29a901f9e
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
@@ -0,0 +1,71 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
new file mode 100644
index 000000000..4c1a258ef
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
@@ -0,0 +1,61 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
+ [0, 1, 0, 1, 2]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
+ [0, 1, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-9, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
new file mode 100644
index 000000000..bb27644bf
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
@@ -0,0 +1,45 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-10, 0),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
+ [2, 3, 4, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js
new file mode 100644
index 000000000..2afbf0dd2
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js
@@ -0,0 +1,77 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -1),
+ [3, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -2),
+ [0, 1, 3, 4, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(1, -2),
+ [0, 3, 4, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, -2),
+ [0, 1, 2, 2]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2),
+ [3, 4, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js b/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js
new file mode 100644
index 000000000..6337ba68e
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js
@@ -0,0 +1,53 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, 0),
+ [0, 1, 2, 0]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, 2),
+ [0, 1, 2, 2]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js
new file mode 100644
index 000000000..f5f1b77bb
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, 6),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
+ [0, 3, 4, 5, 4, 5]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
new file mode 100644
index 000000000..6fc8351a5
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
@@ -0,0 +1,50 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
new file mode 100644
index 000000000..4643c7ce9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
@@ -0,0 +1,50 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0),
+ [1, 2, 3, 4, 5, 6]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2),
+ [3, 4, 5, 6, 5, 6]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0),
+ [1, 2, 3, 1, 2, 3]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4),
+ [0, 4, 5, 3, 4, 5]
+ )
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
new file mode 100644
index 000000000..1e56bd582
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
@@ -0,0 +1,73 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 0, 0),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 0, 2),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, 2),
+ [1, 1, 2, 3]
+ ),
+ '[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([0, 1, 2, 3]).copyWithin(1, 0, 2),
+ [0, 0, 1, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5),
+ [0, 3, 4, 3, 4, 5]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js
new file mode 100644
index 000000000..4f947ab80
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-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
+es6id: 22.2.3.5
+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).
+ ...
+features: [Symbol]
+includes: [testTypedArray.js]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, 0, s);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js
new file mode 100644
index 000000000..24e9d6183
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js
@@ -0,0 +1,39 @@
+// 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
+es6id: 22.2.3.5
+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: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, 0, o1);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js
new file mode 100644
index 000000000..830d597b9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.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
+es6id: 22.2.3.5
+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).
+ ...
+features: [Symbol]
+includes: [testTypedArray.js]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, s);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js
new file mode 100644
index 000000000..9608d66cd
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js
@@ -0,0 +1,45 @@
+// 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
+es6id: 22.2.3.5
+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: [testTypedArray.js]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var err = {
+ valueOf: function() {
+ throw new Error("ToInteger(start) runs before ToInteger(end)");
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, o, err);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js
new file mode 100644
index 000000000..393a0d21d
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.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
+es6id: 22.2.3.5
+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).
+ ...
+features: [Symbol]
+includes: [testTypedArray.js]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(s, 0);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js
new file mode 100644
index 000000000..f599f4a14
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js
@@ -0,0 +1,39 @@
+// 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
+es6id: 22.2.3.5
+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: [testTypedArray.js]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(o);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/return-this.js b/test/built-ins/TypedArray/prototype/copyWithin/return-this.js
new file mode 100644
index 000000000..bab0f7c57
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/return-this.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
+es6id: 22.2.3.5
+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: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.copyWithin(0, 0);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA([1, 2, 3]);
+ var result2 = sample2.copyWithin(1, 0);
+
+ assert.sameValue(result2, sample2);
+});
diff --git a/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js b/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js
new file mode 100644
index 000000000..bbb30675f
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js
@@ -0,0 +1,45 @@
+// 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
+es6id: 22.2.3.5
+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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
+ );
+});