Skip to content
Snippets Groups Projects
Commit 574c87b1 authored by Rick Waldron's avatar Rick Waldron
Browse files

Merge pull request #390 from bocoup/Array.prototype.copyWithin

Add tests for Array.prototype.copyWithin
parents 50423896 e72f4bcd
Branches
No related tags found
No related merge requests found
Showing
with 967 additions and 0 deletions
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
end argument is coerced to an integer values.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, null),
[0, 1, 2, 3]
),
'null value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, NaN),
[0, 1, 2, 3]
),
'NaN value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, false),
[0, 1, 2, 3]
),
'false value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, true),
[0, 0, 2, 3]
),
'true value coerced to 1'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, '-2'),
[0, 0, 1, 3]
),
'string "-2" value coerced to integer -2'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0, -2.5),
[0, 0, 1, 3]
),
'float -2.5 value coerced to integer -2'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
start argument is coerced to an integer value.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
8. Let relativeStart be ToInteger(start).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, undefined),
[0, 0, 1, 2]
),
'undefined value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, false),
[0, 0, 1, 2]
),
'false value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, NaN),
[0, 0, 1, 2]
),
'NaN value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, null),
[0, 0, 1, 2]
),
'null value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0, true),
[1, 2, 3, 3]
),
'true value coerced to 1'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0, '1'),
[1, 2, 3, 3]
),
'string "1" value coerced to 1'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1, 0.5),
[0, 0, 1, 2]
),
'0.5 float value coerced to integer 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0, 1.5),
[1, 2, 3, 3]
),
'1.5 float value coerced to integer 1'
);
\ No newline at end of file
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
target argument is coerced to an integer value.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
5. Let relativeTarget be ToInteger(target).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(undefined, 1),
[1, 2, 3, 3]
),
'undefined value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(false, 1),
[1, 2, 3, 3]
),
'false value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(NaN, 1),
[1, 2, 3, 3]
),
'NaN value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(null, 1),
[1, 2, 3, 3]
),
'null value coerced to 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(true, 0),
[0, 0, 1, 2]
),
'true value coerced to 1'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin('1', 0),
[0, 0, 1, 2]
),
'string "1" value coerced to 1'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0.5, 1),
[1, 2, 3, 3]
),
'0.5 float value coerced to integer 0'
);
assert(
compareArray(
[0, 1, 2, 3].copyWithin(1.5, 0),
[0, 0, 1, 2]
),
'1.5 float value coerced to integer 1'
);
\ No newline at end of file
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: Property type and descriptor.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(
typeof Array.prototype.copyWithin,
'function',
'`typeof Array.prototype.copyWithin` is `function`'
);
verifyNotEnumerable(Array.prototype, 'copyWithin');
verifyWritable(Array.prototype, 'copyWithin');
verifyConfigurable(Array.prototype, 'copyWithin');
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Loop from each property, even empty holes.
---*/
var arr = [0, 1, , , 1];
arr.copyWithin(0, 1, 4);
assert.sameValue(arr.length, 5);
assert.sameValue(arr[0], 1);
assert.sameValue(arr[4], 1);
assert.sameValue(arr.hasOwnProperty(1), false);
assert.sameValue(arr.hasOwnProperty(2), false);
assert.sameValue(arr.hasOwnProperty(3), false);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: Array.prototype.copyWithin.length value and descriptor.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
The length property of the copyWithin method is 2.
includes: [propertyHelper.js]
---*/
assert.sameValue(
Array.prototype.copyWithin.length, 2,
'The value of `Array.prototype.copyWithin.length` is `2`'
);
verifyNotEnumerable(Array.prototype.copyWithin, 'length');
verifyNotWritable(Array.prototype.copyWithin, 'length');
verifyConfigurable(Array.prototype.copyWithin, 'length');
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Array.prototype.copyWithin.name value and descriptor.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(
Array.prototype.copyWithin.name, 'copyWithin',
'The value of `Array.prototype.copyWithin.name` is `"copyWithin"`'
);
verifyNotEnumerable(Array.prototype.copyWithin, 'name');
verifyNotWritable(Array.prototype.copyWithin, 'name');
verifyConfigurable(Array.prototype.copyWithin, 'name');
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with negative end argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
12. ReturnIfAbrupt(relativeEnd).
13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[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(
[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(
[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(
[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(
[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(
[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(
[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(
[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]'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with negative out of bounds end argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
12. ReturnIfAbrupt(relativeEnd).
13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[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(
[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(
[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(
[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(
[0, 1, 2, 3].copyWithin(-7, -8, -9),
[0, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
);
\ No newline at end of file
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with out of bounds negative start argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0, -10),
[0, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(0, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
[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(
[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(
[0, 1, 2, 3].copyWithin(-9, -10),
[0, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with out of bounds negative target argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(-10, 0),
[0, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
);
assert(
compareArray(
[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]'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with negative start argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(0, -1),
[3, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
);
assert(
compareArray(
[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(
[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(
[0, 1, 2, 3].copyWithin(-1, -2),
[0, 1, 2, 2]
),
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
);
assert(
compareArray(
[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(
[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]'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Set values with negative target argument.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3].copyWithin(-1, 0),
[0, 1, 2, 0]
),
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
);
assert(
compareArray(
[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(
[0, 1, 2, 3].copyWithin(-1, 2),
[0, 1, 2, 2]
),
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Max value of end position is the this.length.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
...
14. Let count be min(final-from, len-to).
15. If from<to and to<from+count
a. Let direction be -1.
b. Let from be from + count -1.
c. Let to be to + count -1.
16. Else,
a. Let direction = 1.
17. Repeat, while count > 0
...
a. If fromPresent is true, then
i. Let fromVal be Get(O, fromKey).
...
iii. Let setStatus be Set(O, toKey, fromVal, true).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[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(
[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]'
);
\ No newline at end of file
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Max values of target and start positions are this.length.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
...
14. Let count be min(final-from, len-to).
15. If from<to and to<from+count
...
16. Else,
a. Let direction = 1.
17. Repeat, while count > 0
...
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(6, 0),
[0, 1, 2, 3, 4, 5]
)
);
assert(
compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(0, 6),
[0, 1, 2, 3, 4, 5]
)
);
assert(
compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(6, 6),
[0, 1, 2, 3, 4, 5]
)
);
assert(
compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(10, 10),
[0, 1, 2, 3, 4, 5]
)
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Copy values with non-negative target and start positions.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
...
14. Let count be min(final-from, len-to).
15. If from<to and to<from+count
...
16. Else,
a. Let direction = 1.
17. Repeat, while count > 0
...
a. If fromPresent is true, then
i. Let fromVal be Get(O, fromKey).
...
iii. Let setStatus be Set(O, toKey, fromVal, true).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0),
['a', 'b', 'c', 'd', 'e', 'f']
)
);
assert(
compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2),
['c', 'd', 'e', 'f', 'e', 'f']
)
);
assert(
compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0),
['a', 'b', 'c', 'a', 'b', 'c']
)
);
assert(
compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(1, 4),
[0, 4, 5, 3, 4, 5]
)
);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Copy values with non-negative target, start and end positions.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to
be min(relativeTarget, len).
...
10. If relativeStart < 0, let from be max((len + relativeStart),0); else let
from be min(relativeStart, len).
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
...
14. Let count be min(final-from, len-to).
15. If from<to and to<from+count
a. Let direction be -1.
b. Let from be from + count -1.
c. Let to be to + count -1.
16. Else,
a. Let direction = 1.
17. Repeat, while count > 0
...
a. If fromPresent is true, then
i. Let fromVal be Get(O, fromKey).
...
iii. Let setStatus be Set(O, toKey, fromVal, true).
...
includes: [compareArray.js]
---*/
assert(
compareArray(
[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(
[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(
[0, 1, 2, 3].copyWithin(0, 1, 2),
[1, 1, 2, 3]
),
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
);
/*
* 15. If from<to and to<from+count
* 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(
[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(
[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]'
);
\ No newline at end of file
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Return abrupt from deleting property value - using Proxy
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
17. Repeat, while count > 0
a. Let fromKey be ToString(from).
b. Let toKey be ToString(to).
c. Let fromPresent be HasProperty(O, fromKey).
...
f. Else fromPresent is false,
i. Let deleteStatus be DeletePropertyOrThrow(O, toKey).
ii. ReturnIfAbrupt(deleteStatus).
...
features: [Proxy]
---*/
var o = {
'42': true,
length: 43
};
var p = new Proxy(o, {
deleteProperty: function(t, prop) {
if (prop === '42') {
throw new Test262Error();
}
}
});
assert.throws(Test262Error, function() {
Array.prototype.copyWithin.call(p, 42, 0);
});
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Return abrupt from deleting property value on DeletePropertyOrThrow(O, toKey).
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
17. Repeat, while count > 0
a. Let fromKey be ToString(from).
b. Let toKey be ToString(to).
c. Let fromPresent be HasProperty(O, fromKey).
...
f. Else fromPresent is false,
i. Let deleteStatus be DeletePropertyOrThrow(O, toKey).
ii. ReturnIfAbrupt(deleteStatus).
...
---*/
var o = {
length: 43
};
Object.defineProperty(o, '42', {
configurable: false,
writable: true
});
assert.throws(TypeError, function() {
Array.prototype.copyWithin.call(o, 42, 0);
});
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.3.3
description: >
Return abrupt from end as a Symbol.
info: >
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
11. If end is undefined, let relativeEnd be len; else let relativeEnd be
ToInteger(end).
12. ReturnIfAbrupt(relativeEnd).
...
features: [Symbol]
---*/
var s = Symbol(1);
assert.throws(TypeError, function() {
[].copyWithin(0, 0, s);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment