summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray
diff options
context:
space:
mode:
authorGorkem Yakin <goyakin@microsoft.com>2016-04-25 10:46:38 -0700
committerGorkem Yakin <goyakin@microsoft.com>2016-04-25 10:46:38 -0700
commit35c00cab924930537786d93435117c4572d985df (patch)
tree6b8716ac546486a0f14f22c678b9521c45154f8f /test/built-ins/TypedArray
parenta4fd0dc8f4de5244322d3b017f77e46ecfa3a3c0 (diff)
parent45ff661f7592555d2d72a4960afd2fd50fc3a466 (diff)
downloadqtdeclarative-testsuites-35c00cab924930537786d93435117c4572d985df.tar.gz
Merge branch 'bocoup/ta-every-some'
Diffstat (limited to 'test/built-ins/TypedArray')
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js55
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js53
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js43
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js41
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js69
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js35
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js37
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js34
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js58
-rw-r--r--test/built-ins/TypedArray/prototype/every/callbackfn-this.js58
-rw-r--r--test/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js46
-rw-r--r--test/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js45
-rw-r--r--test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js46
-rw-r--r--test/built-ins/TypedArray/prototype/every/values-are-not-cached.js42
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js56
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js54
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js42
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js40
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js69
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js35
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js37
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js34
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js56
-rw-r--r--test/built-ins/TypedArray/prototype/some/callbackfn-this.js56
-rw-r--r--test/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js45
-rw-r--r--test/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js42
-rw-r--r--test/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js60
-rw-r--r--test/built-ins/TypedArray/prototype/some/values-are-not-cached.js40
28 files changed, 1328 insertions, 0 deletions
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 000000000..63d8ba8a1
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,55 @@
+// 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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 000000000..2fba59f03
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.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: >
+ 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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js
new file mode 100644
index 000000000..3d7ce3215
--- /dev/null
+++ b/test/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 ] )
+
+ ...
+ 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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.every(function() {
+ if (loops === 1) {
+ throw new Test262Error("callbackfn called twice");
+ }
+ $DETACHBUFFER(sample.buffer);
+ loops++;
+ return true;
+ });
+ });
+
+ assert.sameValue(loops, 1);
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/test/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 000000000..1fcb162b8
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.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.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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/test/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
new file mode 100644
index 000000000..bfee4bef0
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
@@ -0,0 +1,69 @@
+// 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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js
new file mode 100644
index 000000000..7f399ac9a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js
@@ -0,0 +1,35 @@
+// 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().every(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/test/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 000000000..61c067316
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.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: >
+ 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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/test/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js
new file mode 100644
index 000000000..fdd4bbf28
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.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: 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.every(function() {
+ throw new Test262Error();
+ });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js
new file mode 100644
index 000000000..340b3c438
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.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: >
+ 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]
+---*/
+
+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 interaction"
+ );
+
+ newVal++;
+
+ return true;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after interaction [2] == 2");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/callbackfn-this.js b/test/built-ins/TypedArray/prototype/every/callbackfn-this.js
new file mode 100644
index 000000000..b9baf849a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/callbackfn-this.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: >
+ 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]
+---*/
+
+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]");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/test/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js
new file mode 100644
index 000000000..1e57c468a
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.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]
+---*/
+
+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, "interactions are not affected by custom length");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/test/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js
new file mode 100644
index 000000000..6b984db40
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.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: >
+ 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]
+---*/
+
+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);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js
new file mode 100644
index 000000000..51ff9612e
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.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.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]
+---*/
+
+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");
+});
diff --git a/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js b/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js
new file mode 100644
index 000000000..091ae6a35
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Integer indexed values are not cached before interaction
+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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var calls = 0;
+
+ 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;
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 000000000..c5f89b47c
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-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.some
+description: >
+ thisArg does not affect callbackfn arguments
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.some(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], 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 000000000..19c888e9f
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.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.some
+description: >
+ callbackfn arguments
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.some(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], 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js
new file mode 100644
index 000000000..018060c18
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Instance buffer can be detached during loop
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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, testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.some(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/some/callbackfn-no-interaction-over-non-integer.js b/test/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 000000000..ac405daba
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Does not interact over non-integer properties
+info: >
+ 22.2.3.7 %TypedArray%.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.some(function() {
+ results.push(arguments);
+ });
+
+ 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");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/test/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js
new file mode 100644
index 000000000..7ebc48073
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js
@@ -0,0 +1,69 @@
+// 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.some
+description: Throws a TypeError if callbackfn is not callable
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.some();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.some(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.some(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.some("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.some(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.some(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.some(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.some(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.some({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.some(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.some(Symbol("1"));
+ }, "symbol");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js
new file mode 100644
index 000000000..29be86f5f
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js
@@ -0,0 +1,35 @@
+// 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.some
+description: >
+ callbackfn is not called on empty instances
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().some(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/test/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 000000000..935f55595
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.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.some
+description: >
+ The callbackfn return does not change the instance
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+
+ sample.some(function() {
+ return 0;
+ });
+
+ assert.sameValue(sample[0], 40, "[0] == 40");
+ assert.sameValue(sample[1], 41, "[1] == 41");
+ assert.sameValue(sample[2], 42, "[2] == 42");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/test/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js
new file mode 100644
index 000000000..f41f9abfc
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.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.some
+description: Returns abrupt from callbackfn
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.some(function() {
+ throw new Test262Error();
+ });
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js
new file mode 100644
index 000000000..d9fa9d9d8
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.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.some
+description: >
+ Integer indexed values changed during iteration
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.some(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 interaction"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after interaction [2] == 2");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/callbackfn-this.js b/test/built-ins/TypedArray/prototype/some/callbackfn-this.js
new file mode 100644
index 000000000..2858f69b8
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/callbackfn-this.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.some
+description: >
+ callbackfn `this` value
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.some(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.some(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/some/get-length-uses-internal-arraylength.js b/test/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js
new file mode 100644
index 000000000..6a0b2c915
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.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.some
+description: Get "length" uses internal ArrayLength
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+---*/
+
+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.some(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "interactions are not affected by custom length");
+});
diff --git a/test/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/test/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js
new file mode 100644
index 000000000..658df97a6
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Returns false if every callbackfn calls returns a coerced false.
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ return val;
+ });
+ assert.sameValue(called, 42, "callbackfn called for each index property");
+ assert.sameValue(result, false, "result is false - " + val);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/test/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js
new file mode 100644
index 000000000..1aacdb1bd
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.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.some
+description: >
+ Returns true if any callbackfn returns a coerced true.
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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 »)).
+ iii. If testResult is true, return true.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+ var sample = new TA(42);
+ var values = [
+ true,
+ 1,
+ "test262",
+ s,
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ if (called == 1) {
+ return false;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called for each index property");
+
+ var msg = "result is true - " + (val === s ? "symbol" : val);
+ assert.sameValue(result, true, msg);
+ });
+});
diff --git a/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js b/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js
new file mode 100644
index 000000000..c8ded95d7
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/some/values-are-not-cached.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.some
+description: >
+ Integer indexed values are not cached before interaction
+info: >
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var calls = 0;
+
+ sample.some(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ });
+});