summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray/prototype/reduce
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArray/prototype/reduce')
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js58
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js59
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js44
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js67
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js48
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js39
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js21
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js43
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js49
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js44
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js32
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js41
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js34
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js46
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-func.js30
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-method.js30
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/length.js30
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/name.js27
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/prop-desc.js19
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js59
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js67
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js42
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-object.js51
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-typedarray-instance.js43
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js41
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js1
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/invoked-as-func.js2
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/invoked-as-method.js2
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/length.js3
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/name.js3
-rw-r--r--test/built-ins/TypedArray/prototype/reduce/prop-desc.js3
31 files changed, 1073 insertions, 5 deletions
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js
new file mode 100644
index 000000000..6b54c191c
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js
@@ -0,0 +1,58 @@
+// 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.reduce
+description: >
+ callbackfn arguments using custom accumulator
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ }, 7);
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[0].length");
+ assert.sameValue(results[0][0], 7, "results[0][0] - accumulator");
+ assert.sameValue(results[0][1], 42n, "results[0][1] - kValue");
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[0][3], sample, "results[0][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[1].length");
+ assert.sameValue(results[1][0], 8, "results[1][0] - accumulator");
+ assert.sameValue(results[1][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+ assert.sameValue(results[1][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[2].length, 4, "results[2].length");
+ assert.sameValue(results[2][0], 9, "results[2][0] - accumulator");
+ assert.sameValue(results[2][1], 44n, "results[2][1] - kValue");
+ assert.sameValue(results[2][2], 2, "results[2][2] - k");
+ assert.sameValue(results[2][3], sample, "results[2][3] - this");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js
new file mode 100644
index 000000000..ab9e5a286
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js
@@ -0,0 +1,59 @@
+// 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.reduce
+description: >
+ callbackfn arguments using default accumulator (value at index 0)
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ a. Let kPresent be false.
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator - 1n;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[1].length");
+ assert.sameValue(results[0][0], 42n, "results[1][0] - accumulator");
+ assert.sameValue(results[0][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[0][2], 1, "results[1][2] - k");
+ assert.sameValue(results[0][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[2].length");
+ assert.sameValue(results[1][0], 41n, "results[2][0] - accumulator");
+ assert.sameValue(results[1][1], 44n, "results[2][1] - kValue");
+ assert.sameValue(results[1][2], 2, "results[2][2] - k");
+ assert.sameValue(results[1][3], sample, "results[2][3] - this");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 000000000..f904d53a1
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.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.reduce
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.reduce(function() {
+ if (loops === 1) {
+ throw new Test262Error("callbackfn called twice");
+ }
+ $DETACHBUFFER(sample.buffer);
+ loops++;
+ }, 0);
+ });
+
+ assert.sameValue(loops, 1, "callbackfn called only once");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js
new file mode 100644
index 000000000..36b147501
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js
@@ -0,0 +1,67 @@
+// 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.reduce
+description: >
+ Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.reduce();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.reduce({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.reduce("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(Symbol(""));
+ }, "symbol");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js
new file mode 100644
index 000000000..f8282a42e
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.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.reduce
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.reduce(function() {
+ results.push(arguments);
+ }, 0);
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+
+ assert.sameValue(results[0][1], 7n, "results[0][1] - kValue");
+ assert.sameValue(results[1][1], 8n, "results[1][1] - kValue");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 000000000..8bcbcfd43
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.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.reduce
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().reduce(function() {
+ called++;
+ }, undefined);
+
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 000000000..31785cec9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,21 @@
+// 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.reduce
+description: >
+ The callbackfn return does not change the `this` instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 1n, 0n]);
+
+ sample.reduce(function() {
+ return 42;
+ }, 7);
+
+ assert.sameValue(sample[0], 0n, "[0] == 0");
+ assert.sameValue(sample[1], 1n, "[1] == 1");
+ assert.sameValue(sample[2], 0n, "[2] == 0");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 000000000..25470aff7
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,43 @@
+// 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.reduce
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ });
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ }, 0);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 000000000..d77a8ebda
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js
@@ -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.reduce
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.reduce(function(acc, val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ }, 0);
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js
new file mode 100644
index 000000000..fe364eeac
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.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.reduce
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results = [];
+
+ sample.reduce(function() {
+ results.push(this);
+ }, 0);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(results[0], expected, "[0]");
+ assert.sameValue(results[1], expected, "[1]");
+ assert.sameValue(results[2], expected, "[2]");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js
new file mode 100644
index 000000000..91763bcfb
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js
@@ -0,0 +1,32 @@
+// 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.reduce
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reduce(callbackfn);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js
new file mode 100644
index 000000000..34ed97d79
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.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.reduce
+description: >
+ Returns given initialValue on empty instances without calling callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA().reduce(function() {
+ called = true;
+ }, 42);
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js
new file mode 100644
index 000000000..f903b32a0
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js
@@ -0,0 +1,34 @@
+// 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.reduce
+description: >
+ If len is 0 and initialValue is not present, throw a TypeError exception.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ assert.throws(TypeError, function() {
+ new TA().reduce(function() {
+ called++;
+ });
+ });
+
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 000000000..98ff2510d
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,46 @@
+// 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.reduce
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reduce(function() {
+ calls++;
+ }, 0);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-func.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-func.js
new file mode 100644
index 000000000..6b0406b58
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-func.js
@@ -0,0 +1,30 @@
+// 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.reduce
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+
+assert.sameValue(typeof reduce, 'function');
+
+assert.throws(TypeError, function() {
+ reduce();
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-method.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-method.js
new file mode 100644
index 000000000..609adb498
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/invoked-as-method.js
@@ -0,0 +1,30 @@
+// 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.reduce
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.reduce, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.reduce();
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/length.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/length.js
new file mode 100644
index 000000000..bb04ee94f
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ %TypedArray%.prototype.reduce.length is 1.
+info: |
+ %TypedArray%.prototype.reduce ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduce.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.reduce, "length");
+verifyNotWritable(TypedArray.prototype.reduce, "length");
+verifyConfigurable(TypedArray.prototype.reduce, "length");
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/name.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/name.js
new file mode 100644
index 000000000..e07d1dfa5
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/name.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ %TypedArray%.prototype.reduce.name is "reduce".
+info: |
+ %TypedArray%.prototype.reduce ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduce.name, "reduce");
+
+verifyNotEnumerable(TypedArray.prototype.reduce, "name");
+verifyNotWritable(TypedArray.prototype.reduce, "name");
+verifyConfigurable(TypedArray.prototype.reduce, "name");
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/prop-desc.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/prop-desc.js
new file mode 100644
index 000000000..ed8d8a42c
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/prop-desc.js
@@ -0,0 +1,19 @@
+// 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.reduce
+description: >
+ "reduce" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'reduce');
+verifyWritable(TypedArrayPrototype, 'reduce');
+verifyConfigurable(TypedArrayPrototype, 'reduce');
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js
new file mode 100644
index 000000000..2c424d4c8
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js
@@ -0,0 +1,59 @@
+// 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.reduce
+description: >
+ Returns last accumulator value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var calls, result;
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduce(function() {
+ calls++;
+
+ if (calls == 2) {
+ return 42;
+ }
+ });
+ assert.sameValue(result, 42, "using default accumulator");
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduce(function() {
+ calls++;
+
+ if (calls == 3) {
+ return 7;
+ }
+ }, 0);
+ assert.sameValue(result, 7, "using custom accumulator");
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js
new file mode 100644
index 000000000..e67a68dc3
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js
@@ -0,0 +1,67 @@
+// 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.reduce
+description: >
+ Result can be of any type without any number conversions
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ [
+ ["test262", "string"],
+ ["", "empty string"],
+ [undefined, "undefined"],
+ [null, "null"],
+ [-0, "-0"],
+ [42, "integer"],
+ [NaN, "NaN"],
+ [Infinity, "Infinity"],
+ [0.6, "float number"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol(""), "symbol"],
+ [{}, "object"]
+ ].forEach(function(item) {
+ var result;
+
+ result = sample.reduce(function() {
+ return item[0];
+ });
+ assert.sameValue(result, item[0], item[1] + " - using default accumulator");
+
+ result = sample.reduce(function() {
+ return item[0];
+ }, 0);
+
+ assert.sameValue(result, item[0], item[1] + " - using custom accumulator");
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js
new file mode 100644
index 000000000..766bcdb62
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.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.reduce
+description: >
+ Returns [0] without calling callbackfn if length is 1 and initialValue is not
+ present.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA([42n]).reduce(function() {
+ called = true;
+ });
+
+ assert.sameValue(result, 42n);
+ assert.sameValue(called, false);
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-object.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-object.js
new file mode 100644
index 000000000..14680f3d4
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-object.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.reduce
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduce.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ reduce.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ reduce.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ reduce.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ reduce.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ reduce.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ reduce.call(s, callbackfn);
+}, "this is a Symbol");
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-typedarray-instance.js
new file mode 100644
index 000000000..6dedc8cd2
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/this-is-not-typedarray-instance.js
@@ -0,0 +1,43 @@
+// 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.reduce
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduce.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ reduce.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ reduce.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ reduce.call(dv, callbackfn);
+}, "this is a DataView instance");
diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js
new file mode 100644
index 000000000..5362bf1dd
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.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.reduce
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.reduce(function(a, v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ }, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js
index ac8ddff2e..773b4b4c2 100644
--- a/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js
+++ b/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js
@@ -23,6 +23,7 @@ info: |
k, O »).
...
includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {
diff --git a/test/built-ins/TypedArray/prototype/reduce/invoked-as-func.js b/test/built-ins/TypedArray/prototype/reduce/invoked-as-func.js
index ab7b67039..bf5bf5e10 100644
--- a/test/built-ins/TypedArray/prototype/reduce/invoked-as-func.js
+++ b/test/built-ins/TypedArray/prototype/reduce/invoked-as-func.js
@@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.19
+esid: sec-%typedarray%.prototype.reduce
description: Throws a TypeError exception when invoked as a function
info: |
22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
diff --git a/test/built-ins/TypedArray/prototype/reduce/invoked-as-method.js b/test/built-ins/TypedArray/prototype/reduce/invoked-as-method.js
index e50473401..b35bef486 100644
--- a/test/built-ins/TypedArray/prototype/reduce/invoked-as-method.js
+++ b/test/built-ins/TypedArray/prototype/reduce/invoked-as-method.js
@@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.19
+esid: sec-%typedarray%.prototype.reduce
description: Requires a [[TypedArrayName]] internal slot.
info: |
22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
diff --git a/test/built-ins/TypedArray/prototype/reduce/length.js b/test/built-ins/TypedArray/prototype/reduce/length.js
index 7bf2e6f01..9d4afc624 100644
--- a/test/built-ins/TypedArray/prototype/reduce/length.js
+++ b/test/built-ins/TypedArray/prototype/reduce/length.js
@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.19
+esid: sec-%typedarray%.prototype.reduce
description: >
%TypedArray%.prototype.reduce.length is 1.
info: |
@@ -20,6 +20,7 @@ info: |
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
---*/
assert.sameValue(TypedArray.prototype.reduce.length, 1);
diff --git a/test/built-ins/TypedArray/prototype/reduce/name.js b/test/built-ins/TypedArray/prototype/reduce/name.js
index 33cf84edb..9074a96d4 100644
--- a/test/built-ins/TypedArray/prototype/reduce/name.js
+++ b/test/built-ins/TypedArray/prototype/reduce/name.js
@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.19
+esid: sec-%typedarray%.prototype.reduce
description: >
%TypedArray%.prototype.reduce.name is "reduce".
info: |
@@ -17,6 +17,7 @@ info: |
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
---*/
assert.sameValue(TypedArray.prototype.reduce.name, "reduce");
diff --git a/test/built-ins/TypedArray/prototype/reduce/prop-desc.js b/test/built-ins/TypedArray/prototype/reduce/prop-desc.js
index d291e79bc..338776d73 100644
--- a/test/built-ins/TypedArray/prototype/reduce/prop-desc.js
+++ b/test/built-ins/TypedArray/prototype/reduce/prop-desc.js
@@ -1,7 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.19
+esid: sec-%typedarray%.prototype.reduce
description: >
"reduce" property of TypedArrayPrototype
info: |
@@ -9,6 +9,7 @@ info: |
and in Annex B.2 has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;