summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray
diff options
context:
space:
mode:
authorLeonardo Balter <leonardo.balter@gmail.com>2016-04-12 19:10:06 -0400
committerMike Pennisi <mike@mikepennisi.com>2016-04-20 14:05:38 -0400
commit5e8b661050bf1d4395ad5760813db571f14991c7 (patch)
tree94936e36f705bf54ee37c5b335f91402513cea36 /test/built-ins/TypedArray
parentcf68c3be91bd338ebc2e6b5122775a884516d993 (diff)
downloadqtdeclarative-testsuites-5e8b661050bf1d4395ad5760813db571f14991c7.tar.gz
Add tests for TypedArrays fill
Diffstat (limited to 'test/built-ins/TypedArray')
-rw-r--r--test/built-ins/TypedArray/prototype/fill/coerced-indexes.js104
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js42
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js76
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js53
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js51
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js48
-rw-r--r--test/built-ins/TypedArray/prototype/fill/fill-values.js44
-rw-r--r--test/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js51
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js39
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js42
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js50
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js38
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js41
-rw-r--r--test/built-ins/TypedArray/prototype/fill/return-this.js20
14 files changed, 699 insertions, 0 deletions
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 000000000..414a5c7a5
--- /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 000000000..f0e10064c
--- /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 000000000..e5e11f146
--- /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 000000000..9fc77fdcd
--- /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 000000000..e9f550646
--- /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 000000000..d39d6221b
--- /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 000000000..7d3ba010b
--- /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 000000000..8bc738477
--- /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 000000000..4b2208f21
--- /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 000000000..1d7c9f70f
--- /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 000000000..3d255b593
--- /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 000000000..150be65a1
--- /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 000000000..55cac4c35
--- /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 000000000..ce3844fc8
--- /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);
+});