Update tests for TypedArrays foreach and map

Based on the feedback from gh-593
This commit is contained in:
Leonardo Balter 2016-04-22 18:22:49 -04:00 committed by Gorkem Yakin
parent 9aa4dced8d
commit afd44fc87a
4 changed files with 59 additions and 4 deletions

View File

@ -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");

View File

@ -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"
);
});
});

View File

@ -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");

View File

@ -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"
);
});
});