summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray/prototype/filter/BigInt
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArray/prototype/filter/BigInt')
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js39
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js46
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js44
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js39
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js39
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js34
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js38
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js58
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js27
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js23
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js27
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js47
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js48
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js32
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-func.js30
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-method.js30
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/length.js29
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/name.js26
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/prop-desc.js18
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js27
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js36
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js38
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js43
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js64
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js65
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js54
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js45
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js59
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js41
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js46
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js54
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js46
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js56
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js66
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js54
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js46
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-object.js53
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-typedarray-instance.js45
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js31
-rw-r--r--test/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js30
40 files changed, 1673 insertions, 0 deletions
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/test/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js
new file mode 100644
index 000000000..ecd36aa8a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.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.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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 000000000..d0d796be5
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-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: >
+ 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(convertToBigInt([42, 43, 44]));
+
+ 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], convertToBigInt(42), "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], convertToBigInt(43), "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], convertToBigInt(44), "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 000000000..ca3e078d2
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.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.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(convertToBigInt([42, 43, 44]));
+
+ 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], convertToBigInt(42), "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], convertToBigInt(43), "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], convertToBigInt(44), "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js
new file mode 100644
index 000000000..56c07c040
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.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.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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js
new file mode 100644
index 000000000..e99e1b715
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.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.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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 000000000..ff563cd3a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.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: >
+ 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]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() {
+ if (loops === 1) {
+ throw new Test262Error("callbackfn called twice");
+ }
+ $DETACHBUFFER(sample.buffer);
+ loops++;
+ });
+ });
+
+ assert.sameValue(loops, 1);
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js
new file mode 100644
index 000000000..b980efe72
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.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: >
+ 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(convertToBigInt([7, 8]));
+
+ 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], convertToBigInt(7), "results[0][0] - kValue");
+ assert.sameValue(results[1][0], convertToBigInt(8), "results[1][0] - kValue");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 000000000..6d2c4a71a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.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: 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 000000000..47cc032e0
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,27 @@
+// 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);
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 000000000..4bac77886
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,23 @@
+// 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] = convertToBigInt(1);
+
+ sample1.filter(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], convertToBigInt(0), "[0] == 0");
+ assert.sameValue(sample1[1], convertToBigInt(1), "[1] == 1");
+ assert.sameValue(sample1[2], convertToBigInt(0), "[2] == 0");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 000000000..411b5ef8c
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,27 @@
+// 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();
+ });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 000000000..a4e86b427
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.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: >
+ 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(convertToBigInt([42, 43, 44]));
+ var newVal = 0;
+
+ sample.filter(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], convertToBigInt(newVal - 1),
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, convertToBigInt(7)),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, convertToBigInt(newVal)),
+ true,
+ "set value during interaction"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], convertToBigInt(7), "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], convertToBigInt(1), "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], convertToBigInt(2), "changed values after interaction [2] == 2");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js
new file mode 100644
index 000000000..fc7e0bccb
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.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: >
+ 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]");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js
new file mode 100644
index 000000000..19539b599
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/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.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);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-func.js b/test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-func.js
new file mode 100644
index 000000000..86c878c88
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/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.
+/*---
+es6id: 22.2.3.9
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 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 filter = TypedArray.prototype.filter;
+
+assert.sameValue(typeof filter, 'function');
+
+assert.throws(TypeError, function() {
+ filter();
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-method.js b/test/built-ins/TypedArray/prototype/filter/BigInt/invoked-as-method.js
new file mode 100644
index 000000000..0c70719e1
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/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.
+/*---
+es6id: 22.2.3.9
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 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.filter, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.filter();
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/length.js b/test/built-ins/TypedArray/prototype/filter/BigInt/length.js
new file mode 100644
index 000000000..2b5d020a3
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.3.9
+description: >
+ %TypedArray%.prototype.filter.length is 1.
+info: |
+ %TypedArray%.prototype.filter ( 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]
+---*/
+
+assert.sameValue(TypedArray.prototype.filter.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.filter, "length");
+verifyNotWritable(TypedArray.prototype.filter, "length");
+verifyConfigurable(TypedArray.prototype.filter, "length");
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/name.js b/test/built-ins/TypedArray/prototype/filter/BigInt/name.js
new file mode 100644
index 000000000..f582e69dd
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/name.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.3.9
+description: >
+ %TypedArray%.prototype.filter.name is "filter".
+info: |
+ %TypedArray%.prototype.filter ( 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]
+---*/
+
+assert.sameValue(TypedArray.prototype.filter.name, "filter");
+
+verifyNotEnumerable(TypedArray.prototype.filter, "name");
+verifyNotWritable(TypedArray.prototype.filter, "name");
+verifyConfigurable(TypedArray.prototype.filter, "name");
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/prop-desc.js b/test/built-ins/TypedArray/prototype/filter/BigInt/prop-desc.js
new file mode 100644
index 000000000..898755704
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/prop-desc.js
@@ -0,0 +1,18 @@
+// 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.9
+description: >
+ "filter" 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]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'filter');
+verifyWritable(TypedArrayPrototype, 'filter');
+verifyConfigurable(TypedArrayPrototype, 'filter');
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/test/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
new file mode 100644
index 000000000..1a84196dc
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
@@ -0,0 +1,27 @@
+// 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(convertToBigInt([40, 41, 42]));
+ 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);
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/test/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js
new file mode 100644
index 000000000..34058a260
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js
@@ -0,0 +1,36 @@
+// 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);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/test/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js
new file mode 100644
index 000000000..d63ba8691
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.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 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(convertToBigInt([40, 41, 42]));
+
+ [
+ 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);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 000000000..9b7bc9dfc
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-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.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(convertToBigInt([40, 41, 42, 43]));
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ return true;
+ });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 000000000..35fe965b0
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,64 @@
+// 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(convertToBigInt([40, 41, 42, 43]));
+ 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"
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 000000000..79e40b47c
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,65 @@
+// 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(convertToBigInt([40, 41, 42, 43]));
+
+ 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 000000000..0b64ac3ca
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,54 @@
+// 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(convertToBigInt([40, 41, 42, 43]));
+ 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"
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 000000000..eb585beb7
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-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: >
+ 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; });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 000000000..1efefe1be
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.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.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(convertToBigInt([40, 42, 42]));
+ 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 === convertToBigInt(42); });
+
+ 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"
+ );
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 000000000..80b0ea9f9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.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: >
+ 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; });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 000000000..38af74b53
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.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: >
+ 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 000000000..31f2887b3
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,54 @@
+// 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(convertToBigInt([40]));
+ var otherTA = TA === Int8Array ? Int16Array : Int8Array;
+ var other = new otherTA([1, 0, 1]);
+ 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, [1, 0, 1]), "the returned object is preserved");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 000000000..ae5d33183
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.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: >
+ 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() {});
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 000000000..f881f792d
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-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 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(convertToBigInt([40, 41, 42]));
+ 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, convertToBigInt([40, 41, 42])), "values are set on the new obj");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 000000000..12a76cdda
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.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: >
+ 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 000000000..9ecb72b05
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,54 @@
+// 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js
new file mode 100644
index 000000000..04e413a38
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.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: >
+ 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);
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-object.js b/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-object.js
new file mode 100644
index 000000000..0a8a31a27
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 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 filter = TypedArray.prototype.filter;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ filter.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ filter.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ filter.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ filter.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ filter.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ filter.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ filter.call(s, callbackfn);
+}, "this is a Symbol");
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-typedarray-instance.js
new file mode 100644
index 000000000..4bb60e605
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/this-is-not-typedarray-instance.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: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 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 filter = TypedArray.prototype.filter;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ filter.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ filter.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ filter.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ filter.call(dv, callbackfn);
+}, "this is a DataView instance");
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
new file mode 100644
index 000000000..25b7eb24a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
@@ -0,0 +1,31 @@
+// 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(convertToBigInt([42, 43, 44]));
+
+ sample.filter(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = convertToBigInt(42);
+ }
+
+ assert.sameValue(
+ v, convertToBigInt(42), "method does not cache values before callbackfn calls"
+ );
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js b/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js
new file mode 100644
index 000000000..b7f2775f2
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.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.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(convertToBigInt([41, 1, 42, 7]));
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert(compareArray(result, convertToBigInt([41, 1, 42, 7])), "values are set #1");
+
+ result = sample.filter(function(v) {
+ return v > convertToBigInt(40);
+ });
+ assert(compareArray(result, convertToBigInt([41, 42])), "values are set #2");
+});