mirror of https://github.com/tc39/test262.git
Update tests for TypedArrays foreach and map
Based on the feedback from gh-593
This commit is contained in:
parent
9aa4dced8d
commit
afd44fc87a
|
@ -27,8 +27,8 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
sample.foo = 42;
|
||||
sample[Symbol("1")] = 43;
|
||||
|
||||
sample.forEach(function(v, i) {
|
||||
results.push([v, i]);
|
||||
sample.forEach(function() {
|
||||
results.push(arguments);
|
||||
});
|
||||
|
||||
assert.sameValue(results.length, 2, "results.length");
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.foreach
|
||||
description: >
|
||||
Integer indexed values are not cached before interaction
|
||||
info: >
|
||||
22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
%TypedArray%.prototype.forEach is a distinct function that implements the same
|
||||
algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
|
||||
this object's [[ArrayLength]] internal slot is accessed in place of performing
|
||||
a [[Get]] of "length"
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43, 44]);
|
||||
|
||||
sample.forEach(function(v, i) {
|
||||
if (i < sample.length - 1) {
|
||||
sample[i+1] = 42;
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
v, 42, "method does not cache values before callbackfn calls"
|
||||
);
|
||||
});
|
||||
});
|
|
@ -26,8 +26,8 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
sample.foo = 42;
|
||||
sample[Symbol("1")] = 43;
|
||||
|
||||
sample.map(function(v, i) {
|
||||
results.push([v, i]);
|
||||
sample.map(function() {
|
||||
results.push(arguments);
|
||||
});
|
||||
|
||||
assert.sameValue(results.length, 2, "results.length");
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.map
|
||||
description: >
|
||||
Integer indexed values changed during iteration
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43, 44]);
|
||||
|
||||
sample.map(function(v, i) {
|
||||
if (i < sample.length - 1) {
|
||||
sample[i+1] = 42;
|
||||
}
|
||||
|
||||
assert.sameValue(
|
||||
v, 42, "method does not cache values before callbackfn calls"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue