summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js32
36 files changed, 1615 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..5582bb10f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.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.filter
+description: Uses internal ArrayLength instead of length property
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+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(4);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 4, "interactions are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..7d827de7d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.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.filter
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.filter(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..ed033a7010
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.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.filter
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js
new file mode 100644
index 0000000000..af35a1f777
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.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.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js
new file mode 100644
index 0000000000..3cf2636d01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.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.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..30e4e3c3eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2021 Apple Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.filter(function() {
+ var flag = true;
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ } else {
+ flag = false;
+ }
+ loops++;
+ return flag;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js
new file mode 100644
index 0000000000..754091ed37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js
@@ -0,0 +1,40 @@
+// 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.filter
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « 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.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..5b718c30ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js
@@ -0,0 +1,60 @@
+// 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.filter
+description: Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+
+ assert.throws(TypeError, function() {
+ sample.filter();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.filter(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.filter(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.filter(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.filter(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.filter({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.filter([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.filter(1);
+ }, "Number");
+
+ assert.throws(TypeError, function() {
+ sample.filter(Symbol(""));
+ }, "symbol");
+
+ assert.throws(TypeError, function() {
+ sample.filter("");
+ }, "string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..c8d6283ac7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,29 @@
+// 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.filter
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().filter(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..c8e6941ccd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,25 @@
+// 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.filter
+description: >
+ The callbackfn return does not change the instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1n;
+
+ sample1.filter(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0n, "[0] == 0");
+ assert.sameValue(sample1[1], 1n, "[1] == 1");
+ assert.sameValue(sample1[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..7c45962521
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,29 @@
+// 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.filter
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..4d1e9cfe18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/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.filter
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.filter(function(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 interaction"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after interaction [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..5054983356
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.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.filter
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.filter(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.filter(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..87fe78c8de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.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.filter
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 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.filter(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
new file mode 100644
index 0000000000..84fce65efa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
@@ -0,0 +1,29 @@
+// 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.filter
+description: >
+ Return does not share buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+ 13. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert.notSameValue(result.buffer, sample.buffer);
+
+ result = sample.filter(function() { return false; });
+ assert.notSameValue(result.buffer, sample.buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js
new file mode 100644
index 0000000000..7787154e72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.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.filter
+description: >
+ Returns empty if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var result = sample.filter(function() {
+ return val;
+ });
+ assert.sameValue(result.length, 0, val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js
new file mode 100644
index 0000000000..82c7e57468
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js
@@ -0,0 +1,40 @@
+// 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.filter
+description: >
+ Returns full length result if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+
+ [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var result = sample.filter(function() { return val; });
+ assert(compareArray(result, sample), val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f16b6b0daf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.filter,
+ 'function',
+ 'implements TypedArray.prototype.filter'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.filter(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.filter(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the filter operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.filter(() => {});
+ throw new Test262Error('filter completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of BigInt TypedArray objects.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..2c15f6ec0c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,45 @@
+// 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.filter
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ return true;
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..43dbbe8f05
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,66 @@
+// 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.filter
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() {
+ return true;
+ });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..aeddd45fb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-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.filter
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var callbackfn = function() { return true; };
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..38dac21933
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// 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.filter
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..b86692f869
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// 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.filter
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..a4e39abc2e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// 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.filter
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 42n, 42n]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.filter(function(v) { return v === 42n; });
+
+ assert.sameValue(result.length, 1, "called with 1 argument");
+ assert.sameValue(result[0], 2, "[0] is the new captured length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..e92ed32146
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.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.filter
+description: >
+ Throws a TypeError if new typedArray's length < captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..a26cef8c1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.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.filter
+description: >
+ Does not throw a TypeError if new typedArray's length >= captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..1fb32b4b51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,56 @@
+// 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.filter
+description: >
+ Custom @@species constructor may return a different TypedArray
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n]);
+ var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var other = new otherTA([1n, 0n, 1n]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..fd0d97649c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-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.filter
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = Array;
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..afbf9e9472
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.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.filter
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var calls = 0;
+ var other, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(captured) {
+ calls++;
+ other = new TA(captured);
+ return other;
+ };
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert.sameValue(result, other, "return is instance of custom constructor");
+ assert(compareArray(result, [40n, 41n, 42n]), "values are set on the new obj");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..e5830cea73
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// 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.filter
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..75819af3c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// 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.filter
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js
new file mode 100644
index 0000000000..71bc8f62df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.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.filter
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.filter(function() {});
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..66429b4a61
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
@@ -0,0 +1,33 @@
+// 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.filter
+description: >
+ Integer indexed values are not cached before interaction
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.filter(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js
new file mode 100644
index 0000000000..57618c84c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.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.filter
+description: >
+ Returned instance with filtered values set on it
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([41n, 1n, 42n, 7n]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert(compareArray(result, [41n, 1n, 42n, 7n]), "values are set #1");
+
+ result = sample.filter(function(v) {
+ return v > 40n;
+ });
+ assert(compareArray(result, [41n, 42n]), "values are set #2");
+});
+
+reportCompare(0, 0);