mirror of https://github.com/tc39/test262.git
Add tests for TypedArrays copyWithin
This commit is contained in:
parent
5e8b661050
commit
88f390d189
|
@ -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'
|
||||
);
|
||||
});
|
|
@ -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'
|
||||
);
|
||||
});
|
|
@ -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'
|
||||
);
|
||||
});
|
49
test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
vendored
Normal file
49
test/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
vendored
Normal file
|
@ -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);
|
||||
});
|
|
@ -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]'
|
||||
);
|
||||
});
|
71
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
vendored
Normal file
71
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
vendored
Normal file
|
@ -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]'
|
||||
);
|
||||
});
|
61
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
vendored
Normal file
61
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
vendored
Normal file
|
@ -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]'
|
||||
);
|
||||
});
|
45
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
vendored
Normal file
45
test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
vendored
Normal file
|
@ -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]'
|
||||
);
|
||||
});
|
|
@ -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]'
|
||||
);
|
||||
});
|
|
@ -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]'
|
||||
);
|
||||
});
|
38
test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js
vendored
Normal file
38
test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js
vendored
Normal file
|
@ -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]'
|
||||
);
|
||||
});
|
50
test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
vendored
Normal file
|
@ -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]
|
||||
)
|
||||
);
|
||||
});
|
50
test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
vendored
Normal file
|
@ -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]
|
||||
)
|
||||
);
|
||||
});
|
73
test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
vendored
Normal file
73
test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
vendored
Normal file
|
@ -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]'
|
||||
);
|
||||
});
|
37
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js
vendored
Normal file
37
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js
vendored
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
36
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js
vendored
Normal file
36
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js
vendored
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
36
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js
vendored
Normal file
36
test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js
vendored
Normal file
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
|
@ -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]'
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue