summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/prototype/every
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/every')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js44
45 files changed, 2003 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..feb32a4e4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.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.every
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function() {
+ results.push(arguments);
+ return true;
+ }, 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/every/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..7539c73698
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.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.every
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ 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/every/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..dcd3209e2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.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.every
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..44ad01e601
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.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.every
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..d0146e81d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// 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.every
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.every();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.every(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.every(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.every("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.every(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.every(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.every(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.every(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.every({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.every(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.every(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..b933d0618e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.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.every
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().every(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..4de9055dca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.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.every
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+
+ sample.every(function() {
+ return 43;
+ });
+
+ assert.sameValue(sample[0], 40n, "[0] == 40");
+ assert.sameValue(sample[1], 41n, "[1] == 41");
+ assert.sameValue(sample[2], 42n, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..13abf3af2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// 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.every
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..9681d5e39e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.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.every
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(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 iteration"
+ );
+
+ newVal++;
+
+ return true;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..b0a04b738e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.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.every
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult 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.every(function() {
+ results1.push(this);
+ return true;
+ });
+
+ 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.every(function() {
+ results2.push(this);
+ return true;
+ }, 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/every/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..d90c073acb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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.every(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..fabfb42348
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.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.every
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.every(function() {
+ calls++;
+ return true;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..7d9bf0d85f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+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.every,
+ 'function',
+ 'implements TypedArray.prototype.every'
+);
+
+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.every(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.every(() => {});
+
+ 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 every operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.every(() => {});
+ throw new Test262Error('every completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js
new file mode 100644
index 0000000000..20d55bc611
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.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.every
+description: >
+ Returns false if any callbackfn call returns a coerced false.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.every(function() {
+ called++;
+ if (called === 1) {
+ return true;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called until it returned " + val);
+ assert.sameValue(result, false, "result is false when it returned " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js
new file mode 100644
index 0000000000..ecd8112108
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.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.every
+description: >
+ Returns true if every callbackfn returns a coerced true.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+ var values = [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ];
+ var sample = new TA(values.length);
+ var result = sample.every(function() {
+ called++;
+ return values.unshift();
+ });
+
+ assert.sameValue(called, sample.length, "callbackfn called for each index");
+ assert.sameValue(result, true, "return is true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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/every/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..bd074ea54e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.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.every
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult 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.every(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ return true;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..643e3d9ab1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.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.every
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ }, 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], 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], 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], 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");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..3db2e4efb3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.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.every
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 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], 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], 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");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..c31447279d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.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.every
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.every(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..b9f512de47
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.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.every
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..a3a9538f6a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// 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.every
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.every();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.every(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.every(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.every("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.every(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.every(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.every(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.every(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.every({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.every(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.every(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..5218382720
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.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.every
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().every(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js
new file mode 100644
index 0000000000..6dca2c649d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |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.every
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.every(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, true, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.every(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, true, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..8f6678cf55
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.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.every
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+
+ sample.every(function() {
+ return 43;
+ });
+
+ assert.sameValue(sample[0], 40, "[0] == 40");
+ assert.sameValue(sample[1], 41, "[1] == 41");
+ assert.sameValue(sample[2], 42, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..4b7474124c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// 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.every
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.every(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..b9d28709b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.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.every
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.every(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+
+ return true;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js
new file mode 100644
index 0000000000..0619270eaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.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.every
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.every(function() {
+ results1.push(this);
+ return true;
+ });
+
+ 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.every(function() {
+ results2.push(this);
+ return true;
+ }, 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/every/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js
new file mode 100644
index 0000000000..22e87b85f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.every(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..ec9c9ae8ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.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.every
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.every(function() {
+ calls++;
+ return true;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js
new file mode 100644
index 0000000000..c62503b63e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.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.every
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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 )
+
+ 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: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+
+assert.sameValue(typeof every, 'function');
+
+assert.throws(TypeError, function() {
+ every();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js
new file mode 100644
index 0000000000..f7e77e539b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.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.every
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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 )
+
+ 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: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.every, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.every();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js
new file mode 100644
index 0000000000..af76735482
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ %TypedArray%.prototype.every.length is 1.
+info: |
+ %TypedArray%.prototype.every ( 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.every.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.every, "length");
+verifyNotWritable(TypedArray.prototype.every, "length");
+verifyConfigurable(TypedArray.prototype.every, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js
new file mode 100644
index 0000000000..53cae5735e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.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.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ %TypedArray%.prototype.every.name is "every".
+info: |
+ %TypedArray%.prototype.every ( 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.every.name, "every");
+
+verifyNotEnumerable(TypedArray.prototype.every, "name");
+verifyNotWritable(TypedArray.prototype.every, "name");
+verifyConfigurable(TypedArray.prototype.every, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js
new file mode 100644
index 0000000000..16bffa2af1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.every does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.every),
+ false,
+ 'isConstructor(TypedArray.prototype.every) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.every(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.every(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js
new file mode 100644
index 0000000000..f4d99d733a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ "every" 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'every');
+verifyWritable(TypedArrayPrototype, 'every');
+verifyConfigurable(TypedArrayPrototype, 'every');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..2b68002982
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.every,
+ 'function',
+ 'implements TypedArray.prototype.every'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(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.every(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.every(() => {});
+
+ 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 every operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.every(() => {});
+ throw new Test262Error('every completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js
new file mode 100644
index 0000000000..437bfd2b3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.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.every
+description: >
+ Returns false if any callbackfn call returns a coerced false.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.every(function() {
+ called++;
+ if (called === 1) {
+ return true;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called until it returned " + val);
+ assert.sameValue(result, false, "result is false when it returned " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js
new file mode 100644
index 0000000000..b75a13bb27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.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.every
+description: >
+ Returns true if every callbackfn returns a coerced true.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+ var values = [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ];
+ var sample = new TA(values.length);
+ var result = sample.every(function() {
+ called++;
+ return values.unshift();
+ });
+
+ assert.sameValue(called, sample.length, "callbackfn called for each index");
+ assert.sameValue(result, true, "return is true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js
new file mode 100644
index 0000000000..9086272c65
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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 )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ every.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ every.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ every.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ every.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ every.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ every.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ every.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..5d73f3d3d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/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.every
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( 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 )
+
+ 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: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ every.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ every.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ every.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ every.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js
new file mode 100644
index 0000000000..6b64c3fb8d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.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.every
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.every(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ return true;
+ });
+});
+
+reportCompare(0, 0);