mirror of https://github.com/tc39/test262.git
Add tests for TypedArrays map
This commit is contained in:
parent
e01371e12a
commit
f3cc1fb983
|
@ -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.map
|
||||
description: >
|
||||
[[ArrayLength]] is accessed in place of performing a [[Get]] of "length"
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. Let len be the value of O's [[ArrayLength]] internal slot.
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample1 = new TA(42);
|
||||
var loop = 0;
|
||||
|
||||
Object.defineProperty(sample1, "length", {value: 1});
|
||||
|
||||
sample1.map(function() {
|
||||
loop++;
|
||||
});
|
||||
assert.sameValue(loop, 42, "data descriptor");
|
||||
|
||||
loop = 0;
|
||||
var sample2 = new TA(4);
|
||||
Object.defineProperty(sample2, "length", {
|
||||
get: function() {
|
||||
throw new Test262Error(
|
||||
"Does not return abrupt getting length property"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
sample2.map(function() {
|
||||
loop++;
|
||||
});
|
||||
assert.sameValue(loop, 4, "accessor descriptor");
|
||||
});
|
||||
|
46
test/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js
vendored
Normal file
46
test/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js
vendored
Normal file
|
@ -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.map
|
||||
description: >
|
||||
thisArg does not affect callbackfn arguments
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
a. Let Pk be ! ToString(k).
|
||||
b. Let kValue be ? Get(O, Pk).
|
||||
c. Let mappedValue be ? 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.map(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");
|
||||
});
|
44
test/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js
vendored
Normal file
44
test/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js
vendored
Normal file
|
@ -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.map
|
||||
description: >
|
||||
callbackfn arguments
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
a. Let Pk be ! ToString(k).
|
||||
b. Let kValue be ? Get(O, Pk).
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43, 44]);
|
||||
|
||||
var results = [];
|
||||
|
||||
sample.map(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");
|
||||
});
|
|
@ -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.map
|
||||
description: >
|
||||
Instance buffer can be detached during loop
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
b. Let kValue be ? Get(O, Pk).
|
||||
c. Let mappedValue be ? 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.map(function() {
|
||||
if (loops === 1) {
|
||||
throw new Test262Error("callbackfn called twice");
|
||||
}
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
loops++;
|
||||
});
|
||||
});
|
||||
|
||||
assert.sameValue(loops, 1, "callbackfn called only once");
|
||||
});
|
|
@ -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.map
|
||||
description: >
|
||||
callbackfn is not callable
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(3);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map();
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map(undefined);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map(null);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map({});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map(1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map("");
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.map(false);
|
||||
});
|
||||
});
|
40
test/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js
vendored
Normal file
40
test/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js
vendored
Normal file
|
@ -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.map
|
||||
description: >
|
||||
Does not interact over non-integer properties
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
a. Let Pk be ! ToString(k).
|
||||
b. Let kValue be ? Get(O, Pk).
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
includes: [testTypedArray.js, compareArray.js]
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([7, 8]);
|
||||
|
||||
var results = [];
|
||||
|
||||
sample.foo = 42;
|
||||
sample[Symbol("1")] = 43;
|
||||
|
||||
sample.map(function(v, i) {
|
||||
results.push([v, i]);
|
||||
});
|
||||
|
||||
assert.sameValue(results.length, 2, "results.length");
|
||||
|
||||
assert.sameValue(results[0][1], 0, "results[0][1] - k");
|
||||
assert.sameValue(results[1][1], 1, "results[1][1] - k");
|
||||
|
||||
assert.sameValue(results[0][0], 7, "results[0][0] - kValue");
|
||||
assert.sameValue(results[1][0], 8, "results[1][0] - kValue");
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.map
|
||||
description: >
|
||||
callbackfn is not called on empty instances
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
7. Let k be 0.
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var called = 0;
|
||||
|
||||
new TA().map(function() {
|
||||
called++;
|
||||
});
|
||||
|
||||
assert.sameValue(called, 0);
|
||||
});
|
30
test/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js
vendored
Normal file
30
test/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js
vendored
Normal 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.map
|
||||
description: >
|
||||
The callbackfn returned values are applied to the new instance
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
6. Let A be ? TypedArraySpeciesCreate(O, « len »).
|
||||
7. Let k be 0.
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
d. Perform ? Set(A, Pk, mappedValue, true).
|
||||
...
|
||||
9. Return A.
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([1, 2, 4]);
|
||||
var result = sample.map(function(v) {
|
||||
return v * 3;
|
||||
});
|
||||
|
||||
assert.sameValue(result[0], 3, "result[0] == 3");
|
||||
assert.sameValue(result[1], 6, "result[1] == 6");
|
||||
assert.sameValue(result[2], 12, "result[2] == 12");
|
||||
});
|
24
test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js
vendored
Normal file
24
test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// 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: >
|
||||
The callbackfn return does not change the `this` instance
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample1 = new TA(3);
|
||||
|
||||
sample1[1] = 1;
|
||||
|
||||
sample1.map(function() {
|
||||
return 42;
|
||||
});
|
||||
|
||||
assert.sameValue(sample1[0], 0, "[0] == 0");
|
||||
assert.sameValue(sample1[1], 1, "[1] == 1");
|
||||
assert.sameValue(sample1[2], 0, "[2] == 0");
|
||||
});
|
|
@ -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.map
|
||||
description: >
|
||||
Does not copy non-integer properties to returned value
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
a. Let Pk be ! ToString(k).
|
||||
b. Let kValue be ? Get(O, Pk).
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
includes: [testTypedArray.js]
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([7, 8]);
|
||||
var bar = Symbol("1");
|
||||
|
||||
sample.foo = 42;
|
||||
sample[bar]
|
||||
|
||||
var result = sample.map(function() {
|
||||
return 0;
|
||||
});
|
||||
|
||||
assert.sameValue(result.length, 2, "result.length");
|
||||
assert.sameValue(
|
||||
Object.getOwnPropertyDescriptor(result, "foo"),
|
||||
undefined,
|
||||
"foo"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.getOwnPropertyDescriptor(result, bar),
|
||||
undefined,
|
||||
"bar"
|
||||
);
|
||||
});
|
|
@ -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.map
|
||||
description: >
|
||||
Returns abrupt from callbackfn
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(3);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.map(function() {
|
||||
throw new Test262Error();
|
||||
});
|
||||
});
|
||||
});
|
42
test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js
vendored
Normal file
|
@ -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.map
|
||||
description: >
|
||||
Integer indexed values changed during iteration
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
includes: [testTypedArray.js]
|
||||
features: [Reflect.set]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43, 44]);
|
||||
var newVal = 0;
|
||||
|
||||
sample.map(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");
|
||||
});
|
|
@ -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.map
|
||||
description: >
|
||||
callbackfn `this` value
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
...
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
c. Let mappedValue be ? 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.map(function() {
|
||||
results1.push(this);
|
||||
return 0;
|
||||
});
|
||||
|
||||
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.map(function() {
|
||||
results2.push(this);
|
||||
return 0;
|
||||
}, 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]");
|
||||
});
|
37
test/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js
vendored
Normal file
37
test/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js
vendored
Normal file
|
@ -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.map
|
||||
description: |
|
||||
Returns a new typedArray instance from the same constructor with the same
|
||||
length and a new buffer object - testing on an instance with length == 0
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
6. Let A be ? TypedArraySpeciesCreate(O, « len »).
|
||||
7. Let k be 0.
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
9. Return A.
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(0);
|
||||
|
||||
var result = sample.map(function() {});
|
||||
|
||||
assert.notSameValue(result, sample, "new typedArray object");
|
||||
assert.sameValue(result.constructor, TA, "same constructor");
|
||||
assert(result instanceof TA, "result is an instance of " + TA.name);
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(result),
|
||||
Object.getPrototypeOf(sample),
|
||||
"result has the same prototype of sample"
|
||||
);
|
||||
assert.sameValue(result.length, 0, "same length");
|
||||
assert.notSameValue(result.buffer, sample.buffer, "new buffer");
|
||||
});
|
33
test/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js
vendored
Normal file
33
test/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
// 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: |
|
||||
Returns a new typedArray instance from the same constructor with the same
|
||||
length and a new buffer object - testing on an instance with length > 0
|
||||
info: >
|
||||
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
6. Let A be ? TypedArraySpeciesCreate(O, « len »).
|
||||
7. Let k be 0.
|
||||
8. Repeat, while k < len
|
||||
...
|
||||
c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
|
||||
...
|
||||
9. Return A.
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(3);
|
||||
|
||||
var result = sample.map(function(v) {
|
||||
return v;
|
||||
});
|
||||
|
||||
assert.notSameValue(result, sample, "new typedArray object");
|
||||
assert.sameValue(result.constructor, sample.constructor, "same constructor");
|
||||
assert.sameValue(result.length, 3, "same length");
|
||||
assert.notSameValue(result.buffer, sample.buffer, "new buffer");
|
||||
});
|
Loading…
Reference in New Issue