Chromium Code Reviews| Index: test/mjsunit/es6/typedarray-copywithin.js |
| diff --git a/test/mjsunit/es6/typedarray-copywithin.js b/test/mjsunit/es6/typedarray-copywithin.js |
| index ad5a0df5639b1e8724fa5ac70c0f7e4eb2dbe2ec..d7c959437d51d7ddcc3cef6fe585686cae160fd6 100644 |
| --- a/test/mjsunit/es6/typedarray-copywithin.js |
| +++ b/test/mjsunit/es6/typedarray-copywithin.js |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +// Flags: --allow-natives-syntax |
| + |
| var typedArrayConstructors = [ |
| Uint8Array, |
| Int8Array, |
| @@ -171,3 +173,74 @@ CheckEachTypedArray(function copyWithinNullEnd(constructor) { |
| assertArrayEquals([1, 2, 3, 4, 5], |
| new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, null)); |
| }); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinMinusInfinityTarget(constructor) { |
| + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [6, 7, 8, 9, 10, 6, 7, 8, 9, 10]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(-Infinity, 5)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinPositiveInfinityTarget(constructor) { |
| + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(+Infinity, 5)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinMinusInfinityStart(constructor) { |
| + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(5, -Infinity)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinPositiveInfinityStart(constructor) { |
| + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(5, +Infinity)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinMinusInfinityEnd(constructor) { |
| + var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(5, 0, -Infinity)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| + |
| +CheckEachTypedArray(function copyWithinPositiveInfinityEnd(constructor) { |
| +var arr = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + var expected = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]; |
| + |
| + assertArrayEquals(expected, arr.copyWithin(5, 0, +Infinity)); |
| + assertEquals(10, arr.length); |
| +}); |
| + |
| +CheckEachTypedArray(function parametersNotCalledIfDetached(constructor) { |
| + var tmp = { |
| + [Symbol.toPrimitive]() { |
| + assertUnreachable("Parameter should not be processed when " + |
| + "array.[[ViewedArrayBuffer]] is neutered."); |
| + return 0; |
| + } |
| + }; |
| + |
| + var array = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| + %ArrayBufferNeuter(array.buffer); |
| + |
| + // TODO(caitp): this should throw due to being invoked on a TypedArray with a |
|
adamk
2017/02/13 22:44:23
Same thing here as the other TODOs, I'd prefer tha
caitp
2017/02/14 00:34:46
Done.
|
| + // detached buffer. |
| + array.copyWithin(tmp, tmp, tmp); |
|
adamk
2017/02/13 22:44:23
Is there an assertion you can make after the copyW
caitp
2017/02/14 00:34:46
Done
|
| +}); |