diff --git a/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js b/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js new file mode 100644 index 0000000000000000000000000000000000000000..414a5c7a5087896a45bae7ba46b4b5120e2028e9 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js @@ -0,0 +1,104 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Fills elements from coerced to Integer `start` and `end` values +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. 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, 0]).fill(1, undefined), [1, 1]), + '`undefined` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, undefined), [1, 1]), + 'If end is undefined, let relativeEnd be len' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, null), [1, 1]), + '`null` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, null), [0, 0]), + '`null` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, true), [0, 1]), + '`true` start coerced to 1' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, true), [1, 0]), + '`true` end coerced to 1' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, false), [1, 1]), + '`false` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, false), [0, 0]), + '`false` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, NaN), [1, 1]), + '`NaN` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, NaN), [0, 0]), + '`NaN` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, '1'), [0, 1]), + 'string start coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, '1'), [1, 0]), + 'string end coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 1.5), [0, 1]), + 'start as a float number coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, 1.5), [1, 0]), + 'end as a float number coerced' + ); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js new file mode 100644 index 0000000000000000000000000000000000000000..f0e10064cfdfbf3977f9c49282e3eadaf3967df2 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -0,0 +1,42 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Fills all the elements from a with a custom start and end indexes. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. 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, 0, 0]).fill(8, 1, 2), [0, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, 1, 3), [0, 8, 8, 0, 0])); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js b/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js new file mode 100644 index 0000000000000000000000000000000000000000..e5e11f146b8432289725839c5503d64e92421dc4 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -0,0 +1,76 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Fills all the elements with non numeric values values. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42]); + sample.fill(null); + assert.sameValue(sample[0], 0, "null => 0"); + + sample = new TA([42]); + sample.fill(false); + assert.sameValue(sample[0], 0, "false => 0"); + + sample = new TA([42]); + sample.fill(true); + assert.sameValue(sample[0], 1, "true => 1"); + + sample = new TA([42]); + sample.fill("7"); + assert.sameValue(sample[0], 7, "string conversion"); + + sample = new TA([42]); + sample.fill({ + toString: function() { + return 1; + }, + valueOf: function() { + return 7; + } + }); + assert.sameValue(sample[0], 7, "object valueOf conversion before toString"); + + sample = new TA([42]); + sample.fill({ + toString: function() { + return 7; + } + }); + assert.sameValue(sample[0], 7, "object toString when valueOf is absent"); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js b/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js new file mode 100644 index 0000000000000000000000000000000000000000..9fc77fdcdc8606004ff47f3279a9adeaf15d14d7 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.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.fill +es6id: 22.2.3.8 +description: > + Fills all the elements from a with a custom end index. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. 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, 0, 0]).fill(8, 0, 1), [8, 0, 0]), + "Fill elements from custom end position" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0]), + "negative end sets final position to max((length + relativeEnd), 0)" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8]), + "end position is never higher than of length" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0]), + "end position is 0 when (len + relativeEnd) < 0" + ); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js b/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js new file mode 100644 index 0000000000000000000000000000000000000000..e9f55064652a3192294666635083373b86e60d89 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -0,0 +1,51 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Fills all the elements from a with a custom start index. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + ... +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]), + "Fill elements from custom start position" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 4), [0, 0, 0]), + "start position is never higher than length" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, -1), [0, 0, 8]), + "start < 0 sets initial position to max((len + relativeStart), 0)" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, -5), [8, 8, 8]), + "start position is 0 when (len + relativeStart) < 0" + ); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d39d6221bed86cde8b4a9722770d13d2f89007b2 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -0,0 +1,48 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Throws a TypeError if value is a Symbol +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + +features: [Symbol] +includes: [testTypedArray.js] +---*/ + +var s = Symbol('1'); + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.fill(s); + }) +}); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values.js b/test/built-ins/TypedArray/prototype/fill/fill-values.js new file mode 100644 index 0000000000000000000000000000000000000000..7d3ba010bd116eba57439eed2dffee83bf4c463b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/fill-values.js @@ -0,0 +1,44 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Fills all the elements with `value` from a default start and index. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA().fill(8), + [] + ), + "does not fill an empty instance" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8), [8, 8, 8]), + "Default start and end indexes are 0 and this.length" + ); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/test/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc738477e466bfc1d2ee386048f3c9276c6beab --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -0,0 +1,51 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , 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(1); + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + } + }); + + assert.sameValue(sample.fill(1, 0), sample); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..4b2208f216a2edd442c2ad3b08f5d986ee5cf671 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.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.fill +es6id: 22.2.3.8 +description: > + Return abrupt if end is a Symbol. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +features: [Symbol] +includes: [testTypedArray.js] +---*/ + +var end = Symbol(1); + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1, 0, end); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js new file mode 100644 index 0000000000000000000000000000000000000000..1d7c9f70f114c7f3afe6216fdb3174c17443c106 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -0,0 +1,42 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Return abrupt from ToInteger(end). +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +---*/ + +var end = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1, 0, end); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js new file mode 100644 index 0000000000000000000000000000000000000000..3d255b5933994e58414642c50767ce386d8eee73 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.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.fill +es6id: 22.2.3.8 +description: > + Returns abrupt from value set +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA([42]); + var obj = { + valueOf: function() { + throw new Test262Error(); + } + }; + + assert.throws(Test262Error, function() { + sample.fill(obj); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..150be65a1b1a89a8ff1e4f9df6a160133bef7b0b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.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.fill +es6id: 22.2.3.8 +description: > + Return abrupt from ToInteger(start) as a Symbol. +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +features: [Symbol] +includes: [testTypedArray.js] +---*/ + +var start = Symbol(1); + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1, start); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js new file mode 100644 index 0000000000000000000000000000000000000000..55cac4c356c3e1dfd9c557e90f1bb5da8e096135 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -0,0 +1,41 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Return abrupt from ToInteger(start). +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +---*/ + +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1, start); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/return-this.js b/test/built-ins/TypedArray/prototype/fill/return-this.js new file mode 100644 index 0000000000000000000000000000000000000000..ce3844fc8a158b953ff757dec48b8bc0aa502624 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/return-this.js @@ -0,0 +1,20 @@ +// 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.fill +es6id: 22.2.3.8 +description: > + Returns `this`. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample1 = new TA(); + var result1 = sample1.fill(1); + + assert.sameValue(result1, sample1); + + var sample2 = new TA(42); + var result2 = sample2.fill(7); + assert.sameValue(result2, sample2); +});