diff --git a/test/built-ins/Array/prototype/copyWithin/coerced-values-end.js b/test/built-ins/Array/prototype/copyWithin/coerced-values-end.js new file mode 100644 index 0000000000000000000000000000000000000000..1580980b0032fe23dfa927f86ff2f7bdcf3c4f43 --- /dev/null +++ b/test/built-ins/Array/prototype/copyWithin/coerced-values-end.js @@ -0,0 +1,63 @@ +// 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' +); diff --git a/test/built-ins/Array/prototype/copyWithin/coerced-values-start.js b/test/built-ins/Array/prototype/copyWithin/coerced-values-start.js new file mode 100644 index 0000000000000000000000000000000000000000..37d7644f2b1fd1193606bbb501a9b188c04efabe --- /dev/null +++ b/test/built-ins/Array/prototype/copyWithin/coerced-values-start.js @@ -0,0 +1,80 @@ +// 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 diff --git a/test/built-ins/Array/prototype/copyWithin/coerced-values-target.js b/test/built-ins/Array/prototype/copyWithin/coerced-values-target.js new file mode 100644 index 0000000000000000000000000000000000000000..3743bc10347c85f8d356874798508a8f99ea3507 --- /dev/null +++ b/test/built-ins/Array/prototype/copyWithin/coerced-values-target.js @@ -0,0 +1,80 @@ +// 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 diff --git a/test/built-ins/Array/prototype/copyWithin/coerced-values.js b/test/built-ins/Array/prototype/copyWithin/coerced-values.js deleted file mode 100644 index 4f5720bbad18be3b00b704b2b3ae93dfb6e6d553..0000000000000000000000000000000000000000 --- a/test/built-ins/Array/prototype/copyWithin/coerced-values.js +++ /dev/null @@ -1,92 +0,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: > - Arguments are coerced to integer values. -info: > - 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) - - ... - 5. Let relativeTarget be ToInteger(target). - ... - 8. Let relativeStart be ToInteger(start). - ... - 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(undefined, undefined), - [0, 1, 2, 3] - ), - 'undefined `target` and `start` values coerced to 0' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(false, false), - [0, 1, 2, 3] - ), - 'false `target` and `start` values coerced to 0' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(NaN, NaN), - [0, 1, 2, 3] - ), - 'NaN `target` and `start` values coerced to 0' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(null, null), - [0, 1, 2, 3] - ), - 'null `target` and `start` values coerced to 0' -); - - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(true, 0), - [0, 0, 1, 2] - ), - 'true `target` value coerced to 1' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(0, true), - [1, 2, 3, 3] - ), - 'true `start` value coerced to 1' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(1, 0, true), - [0, 0, 2, 3] - ), - 'true `end` value coerced to 1' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin('1', '', '-2'), - [0, 0, 1, 3] - ), - 'string values coerced to integer' -); - -assert( - compareArray( - [0, 1, 2, 3].copyWithin(1.3, 0.4, -2.5), - [0, 0, 1, 3] - ), - 'float values coerced to integer' -); diff --git a/test/built-ins/Array/prototype/copyWithin/fill-holes.js b/test/built-ins/Array/prototype/copyWithin/fill-holes.js index d1b25a2391f9661b259a827680b3fee6299c46bb..a54e655f46b877b96d97428d9e25511e3522c491 100644 --- a/test/built-ins/Array/prototype/copyWithin/fill-holes.js +++ b/test/built-ins/Array/prototype/copyWithin/fill-holes.js @@ -4,12 +4,15 @@ es6id: 22.1.3.3 description: > Loop from each property, even empty holes. -includes: [compareArray.js] ---*/ -assert( - compareArray( - [0, 1, , , 1].copyWithin(0, 1, 4), - [1, , , , 1] - ) -); +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); diff --git a/test/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js b/test/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js index 20f5d7d4462461cc5038ba3927b055c550734f7d..7c8da2671caf58b2c2e5cf3e4c39e25db6b204ec 100644 --- a/test/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js +++ b/test/built-ins/Array/prototype/copyWithin/return-abrupt-from-this-length.js @@ -18,8 +18,7 @@ var o1 = {}; Object.defineProperty(o1, 'length', { get: function() { throw new Test262Error(); - }, - configurable: true + } }); assert.throws(Test262Error, function() { [].copyWithin.call(o1);