mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
Add tests for conversion operations on TypedArrays
This commit is contained in:
parent
b698c8b3ab
commit
04a3c28f7d
@ -46,3 +46,449 @@ function testWithTypedArrayConstructors(f, selected) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for conversion operations on TypedArrays, the expected values
|
||||||
|
* properties are indexed in order to match the respective value for each
|
||||||
|
* TypedArray constructor
|
||||||
|
* @param {Function} fn - the function to call for each constructor and value.
|
||||||
|
* will be called with the constructor, value, expected
|
||||||
|
* value, and a initial value that can be used to avoid
|
||||||
|
* a false positive with an equivalent expected value.
|
||||||
|
*/
|
||||||
|
function testTypedArrayConversions(fn) {
|
||||||
|
var values = [
|
||||||
|
127, // 2 ** 7 - 1
|
||||||
|
128, // 2 ** 7
|
||||||
|
32767, // 2 ** 15 - 1
|
||||||
|
32768, // 2 ** 15
|
||||||
|
2147483647, // 2 ** 31 - 1
|
||||||
|
2147483648, // 2 ** 31
|
||||||
|
255, // 2 ** 8 - 1
|
||||||
|
256, // 2 ** 8
|
||||||
|
65535, // 2 ** 16 - 1
|
||||||
|
65536, // 2 ** 16
|
||||||
|
4294967295, // 2 ** 32 - 1
|
||||||
|
4294967296, // 2 ** 32
|
||||||
|
9007199254740991, // 2 ** 53 - 1
|
||||||
|
9007199254740992, // 2 ** 53
|
||||||
|
1.1,
|
||||||
|
0.1,
|
||||||
|
0.5,
|
||||||
|
0.50000001,
|
||||||
|
0.6,
|
||||||
|
0.7,
|
||||||
|
undefined,
|
||||||
|
-1,
|
||||||
|
-0,
|
||||||
|
-0.1,
|
||||||
|
-1.1,
|
||||||
|
NaN,
|
||||||
|
-127, // - ( 2 ** 7 - 1 )
|
||||||
|
-128, // - ( 2 ** 7 )
|
||||||
|
-32767, // - ( 2 ** 15 - 1 )
|
||||||
|
-32768, // - ( 2 ** 15 )
|
||||||
|
-2147483647, // - ( 2 ** 31 - 1 )
|
||||||
|
-2147483648, // - ( 2 ** 31 )
|
||||||
|
-255, // - ( 2 ** 8 - 1 )
|
||||||
|
-256, // - ( 2 ** 8 )
|
||||||
|
-65535, // - ( 2 ** 16 - 1 )
|
||||||
|
-65536, // - ( 2 ** 16 )
|
||||||
|
-4294967295, // - ( 2 ** 32 - 1 )
|
||||||
|
-4294967296, // - ( 2 ** 32 )
|
||||||
|
Infinity,
|
||||||
|
-Infinity,
|
||||||
|
];
|
||||||
|
|
||||||
|
var expected = {
|
||||||
|
Int8Array: [
|
||||||
|
127, // 127
|
||||||
|
-128, // 128
|
||||||
|
-1, // 32767
|
||||||
|
0, // 32768
|
||||||
|
-1, // 2147483647
|
||||||
|
0, // 2147483648
|
||||||
|
-1, // 255
|
||||||
|
0, // 256
|
||||||
|
-1, // 65535
|
||||||
|
0, // 65536
|
||||||
|
-1, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
-1, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
-1, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
-1, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
-127, // -127
|
||||||
|
-128, // -128
|
||||||
|
1, // -32767
|
||||||
|
0, // -32768
|
||||||
|
1, // -2147483647
|
||||||
|
0, // -2147483648
|
||||||
|
1, // -255
|
||||||
|
0, // -256
|
||||||
|
1, // -65535
|
||||||
|
0, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Uint8Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
255, // 32767
|
||||||
|
0, // 32768
|
||||||
|
255, // 2147483647
|
||||||
|
0, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
0, // 256
|
||||||
|
255, // 65535
|
||||||
|
0, // 65536
|
||||||
|
255, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
255, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
255, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
255, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
129, // -127
|
||||||
|
128, // -128
|
||||||
|
1, // -32767
|
||||||
|
0, // -32768
|
||||||
|
1, // -2147483647
|
||||||
|
0, // -2147483648
|
||||||
|
1, // -255
|
||||||
|
0, // -256
|
||||||
|
1, // -65535
|
||||||
|
0, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Uint8ClampedArray: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
255, // 32767
|
||||||
|
255, // 32768
|
||||||
|
255, // 2147483647
|
||||||
|
255, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
255, // 256
|
||||||
|
255, // 65535
|
||||||
|
255, // 65536
|
||||||
|
255, // 4294967295
|
||||||
|
255, // 4294967296
|
||||||
|
255, // 9007199254740991
|
||||||
|
255, // 9007199254740992
|
||||||
|
1, // 1.1,
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
1, // 0.50000001,
|
||||||
|
1, // 0.6
|
||||||
|
1, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
0, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
0, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
0, // -127
|
||||||
|
0, // -128
|
||||||
|
0, // -32767
|
||||||
|
0, // -32768
|
||||||
|
0, // -2147483647
|
||||||
|
0, // -2147483648
|
||||||
|
0, // -255
|
||||||
|
0, // -256
|
||||||
|
0, // -65535
|
||||||
|
0, // -65536
|
||||||
|
0, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
255, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Int16Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
-32768, // 32768
|
||||||
|
-1, // 2147483647
|
||||||
|
0, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
-1, // 65535
|
||||||
|
0, // 65536
|
||||||
|
-1, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
-1, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
-1, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
-1, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
-127, // -127
|
||||||
|
-128, // -128
|
||||||
|
-32767, // -32767
|
||||||
|
-32768, // -32768
|
||||||
|
1, // -2147483647
|
||||||
|
0, // -2147483648
|
||||||
|
-255, // -255
|
||||||
|
-256, // -256
|
||||||
|
1, // -65535
|
||||||
|
0, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Uint16Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
32768, // 32768
|
||||||
|
65535, // 2147483647
|
||||||
|
0, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
65535, // 65535
|
||||||
|
0, // 65536
|
||||||
|
65535, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
65535, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
65535, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
65535, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
65409, // -127
|
||||||
|
65408, // -128
|
||||||
|
32769, // -32767
|
||||||
|
32768, // -32768
|
||||||
|
1, // -2147483647
|
||||||
|
0, // -2147483648
|
||||||
|
65281, // -255
|
||||||
|
65280, // -256
|
||||||
|
1, // -65535
|
||||||
|
0, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Int32Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
32768, // 32768
|
||||||
|
2147483647, // 2147483647
|
||||||
|
-2147483648, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
65535, // 65535
|
||||||
|
65536, // 65536
|
||||||
|
-1, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
-1, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
-1, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
-1, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
-127, // -127
|
||||||
|
-128, // -128
|
||||||
|
-32767, // -32767
|
||||||
|
-32768, // -32768
|
||||||
|
-2147483647, // -2147483647
|
||||||
|
-2147483648, // -2147483648
|
||||||
|
-255, // -255
|
||||||
|
-256, // -256
|
||||||
|
-65535, // -65535
|
||||||
|
-65536, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Uint32Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
32768, // 32768
|
||||||
|
2147483647, // 2147483647
|
||||||
|
2147483648, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
65535, // 65535
|
||||||
|
65536, // 65536
|
||||||
|
4294967295, // 4294967295
|
||||||
|
0, // 4294967296
|
||||||
|
4294967295, // 9007199254740991
|
||||||
|
0, // 9007199254740992
|
||||||
|
1, // 1.1
|
||||||
|
0, // 0.1
|
||||||
|
0, // 0.5
|
||||||
|
0, // 0.50000001,
|
||||||
|
0, // 0.6
|
||||||
|
0, // 0.7
|
||||||
|
0, // undefined
|
||||||
|
4294967295, // -1
|
||||||
|
0, // -0
|
||||||
|
0, // -0.1
|
||||||
|
4294967295, // -1.1
|
||||||
|
0, // NaN
|
||||||
|
4294967169, // -127
|
||||||
|
4294967168, // -128
|
||||||
|
4294934529, // -32767
|
||||||
|
4294934528, // -32768
|
||||||
|
2147483649, // -2147483647
|
||||||
|
2147483648, // -2147483648
|
||||||
|
4294967041, // -255
|
||||||
|
4294967040, // -256
|
||||||
|
4294901761, // -65535
|
||||||
|
4294901760, // -65536
|
||||||
|
1, // -4294967295
|
||||||
|
0, // -4294967296
|
||||||
|
0, // Infinity
|
||||||
|
0, // -Infinity
|
||||||
|
],
|
||||||
|
Float32Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
32768, // 32768
|
||||||
|
2147483648, // 2147483647
|
||||||
|
2147483648, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
65535, // 65535
|
||||||
|
65536, // 65536
|
||||||
|
4294967296, // 4294967295
|
||||||
|
4294967296, // 4294967296
|
||||||
|
9007199254740992, // 9007199254740991
|
||||||
|
9007199254740992, // 9007199254740992
|
||||||
|
1.100000023841858, // 1.1
|
||||||
|
0.10000000149011612, // 0.1
|
||||||
|
0.5, // 0.5
|
||||||
|
0.5, // 0.50000001,
|
||||||
|
0.6000000238418579, // 0.6
|
||||||
|
0.699999988079071, // 0.7
|
||||||
|
NaN, // undefined
|
||||||
|
-1, // -1
|
||||||
|
-0, // -0
|
||||||
|
-0.10000000149011612, // -0.1
|
||||||
|
-1.100000023841858, // -1.1
|
||||||
|
NaN, // NaN
|
||||||
|
-127, // -127
|
||||||
|
-128, // -128
|
||||||
|
-32767, // -32767
|
||||||
|
-32768, // -32768
|
||||||
|
-2147483648, // -2147483647
|
||||||
|
-2147483648, // -2147483648
|
||||||
|
-255, // -255
|
||||||
|
-256, // -256
|
||||||
|
-65535, // -65535
|
||||||
|
-65536, // -65536
|
||||||
|
-4294967296, // -4294967295
|
||||||
|
-4294967296, // -4294967296
|
||||||
|
Infinity, // Infinity
|
||||||
|
-Infinity, // -Infinity
|
||||||
|
],
|
||||||
|
Float64Array: [
|
||||||
|
127, // 127
|
||||||
|
128, // 128
|
||||||
|
32767, // 32767
|
||||||
|
32768, // 32768
|
||||||
|
2147483647, // 2147483647
|
||||||
|
2147483648, // 2147483648
|
||||||
|
255, // 255
|
||||||
|
256, // 256
|
||||||
|
65535, // 65535
|
||||||
|
65536, // 65536
|
||||||
|
4294967295, // 4294967295
|
||||||
|
4294967296, // 4294967296
|
||||||
|
9007199254740991, // 9007199254740991
|
||||||
|
9007199254740992, // 9007199254740992
|
||||||
|
1.1, // 1.1
|
||||||
|
0.1, // 0.1
|
||||||
|
0.5, // 0.5
|
||||||
|
0.50000001, // 0.50000001,
|
||||||
|
0.6, // 0.6
|
||||||
|
0.7, // 0.7
|
||||||
|
NaN, // undefined
|
||||||
|
-1, // -1
|
||||||
|
-0, // -0
|
||||||
|
-0.1, // -0.1
|
||||||
|
-1.1, // -1.1
|
||||||
|
NaN, // NaN
|
||||||
|
-127, // -127
|
||||||
|
-128, // -128
|
||||||
|
-32767, // -32767
|
||||||
|
-32768, // -32768
|
||||||
|
-2147483647, // -2147483647
|
||||||
|
-2147483648, // -2147483648
|
||||||
|
-255, // -255
|
||||||
|
-256, // -256
|
||||||
|
-65535, // -65535
|
||||||
|
-65536, // -65536
|
||||||
|
-4294967295, // -4294967295
|
||||||
|
-4294967296, // -4294967296
|
||||||
|
Infinity, // Infinity
|
||||||
|
-Infinity, // -Infinity
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
return values.forEach(function(value, index) {
|
||||||
|
var exp = expected[TA.name][index];
|
||||||
|
var initial = 0;
|
||||||
|
if (exp === 0) {
|
||||||
|
initial = 1;
|
||||||
|
}
|
||||||
|
fn(TA, value, exp, initial);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
56
test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js
vendored
Normal file
56
test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js
vendored
Normal file
@ -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.fill
|
||||||
|
es6id: 22.2.3.8
|
||||||
|
description: >
|
||||||
|
Fills all the elements with non numeric values values.
|
||||||
|
info: >
|
||||||
|
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
|
||||||
|
|
||||||
|
%TypedArray%.prototype.fill is a distinct function that implements the same
|
||||||
|
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
|
||||||
|
object's [[ArrayLength]] internal slot is accessed in place of performing a
|
||||||
|
[[Get]] of "length". The implementation of the algorithm may be optimized with
|
||||||
|
the knowledge that the this value is an object that has a fixed length and
|
||||||
|
whose integer indexed properties are not sparse. However, such optimization
|
||||||
|
must not introduce any observable changes in the specified behaviour of the
|
||||||
|
algorithm.
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
7. Repeat, while k < final
|
||||||
|
a. Let Pk be ! ToString(k).
|
||||||
|
b. Perform ? Set(O, Pk, value, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
|
||||||
|
isLittleEndian ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If type is "Float32", then
|
||||||
|
...
|
||||||
|
9. Else, if type is "Float64", then
|
||||||
|
...
|
||||||
|
10. Else,
|
||||||
|
...
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 50 for Element Type type.
|
||||||
|
c. Let intValue be convOp(value).
|
||||||
|
d. If intValue ≥ 0, then
|
||||||
|
...
|
||||||
|
e. Else,
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testTypedArrayConversions(function(TA, value, expected, initial) {
|
||||||
|
var sample = new TA([initial]);
|
||||||
|
|
||||||
|
sample.fill(value);
|
||||||
|
|
||||||
|
assert.sameValue(sample[0], expected, value + " converts to " + expected);
|
||||||
|
});
|
51
test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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: >
|
||||||
|
Verify conversion values on returned instance
|
||||||
|
info: >
|
||||||
|
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
d. Perform ? Set(A, Pk, mappedValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||||
|
...
|
||||||
|
|
||||||
|
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
|
||||||
|
isLittleEndian ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If type is "Float32", then
|
||||||
|
...
|
||||||
|
9. Else, if type is "Float64", then
|
||||||
|
...
|
||||||
|
10. Else,
|
||||||
|
...
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 50 for Element Type type.
|
||||||
|
c. Let intValue be convOp(value).
|
||||||
|
d. If intValue ≥ 0, then
|
||||||
|
...
|
||||||
|
e. Else,
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testTypedArrayConversions(function(TA, value, expected, initial) {
|
||||||
|
var sample = new TA([initial]);
|
||||||
|
|
||||||
|
var result = sample.map(function() {
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(result[0], expected, value + " converts to " + expected);
|
||||||
|
});
|
@ -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-integer-indexed-exotic-objects-defineownproperty-p-desc
|
||||||
|
description: >
|
||||||
|
Verify conversion after defining value
|
||||||
|
info: >
|
||||||
|
9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If Type(P) is String, then
|
||||||
|
...
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
...
|
||||||
|
xi. If Desc has a [[Value]] field, then
|
||||||
|
1. Let value be Desc.[[Value]].
|
||||||
|
2. Return ? IntegerIndexedElementSet(O, intIndex, value).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||||
|
...
|
||||||
|
|
||||||
|
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
|
||||||
|
isLittleEndian ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If type is "Float32", then
|
||||||
|
...
|
||||||
|
9. Else, if type is "Float64", then
|
||||||
|
...
|
||||||
|
10. Else,
|
||||||
|
...
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 50 for Element Type type.
|
||||||
|
c. Let intValue be convOp(value).
|
||||||
|
d. If intValue ≥ 0, then
|
||||||
|
...
|
||||||
|
e. Else,
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testTypedArrayConversions(function(TA, value, expected, initial) {
|
||||||
|
var sample = new TA([initial]);
|
||||||
|
|
||||||
|
Object.defineProperty(sample, "0", {value: value});
|
||||||
|
|
||||||
|
assert.sameValue(sample[0], expected, value + " converts to " + expected);
|
||||||
|
});
|
@ -0,0 +1,50 @@
|
|||||||
|
// 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-integer-indexed-exotic-objects-set-p-v-receiver
|
||||||
|
description: >
|
||||||
|
Verify conversion after setting value
|
||||||
|
info: >
|
||||||
|
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If Type(P) is String, then
|
||||||
|
...
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||||
|
...
|
||||||
|
|
||||||
|
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
|
||||||
|
isLittleEndian ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If type is "Float32", then
|
||||||
|
...
|
||||||
|
9. Else, if type is "Float64", then
|
||||||
|
...
|
||||||
|
10. Else,
|
||||||
|
...
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 50 for Element Type type.
|
||||||
|
c. Let intValue be convOp(value).
|
||||||
|
d. If intValue ≥ 0, then
|
||||||
|
...
|
||||||
|
e. Else,
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testTypedArrayConversions(function(TA, value, expected, initial) {
|
||||||
|
var sample = new TA([initial]);
|
||||||
|
|
||||||
|
sample[0] = value;
|
||||||
|
|
||||||
|
assert.sameValue(sample[0], expected, value + " converts to " + expected);
|
||||||
|
});
|
@ -0,0 +1,52 @@
|
|||||||
|
// 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-object
|
||||||
|
description: >
|
||||||
|
Verify conversion values on returned instance
|
||||||
|
info: >
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat, while k < len
|
||||||
|
...
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
|
||||||
|
...
|
||||||
|
|
||||||
|
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
|
||||||
|
isLittleEndian ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If type is "Float32", then
|
||||||
|
...
|
||||||
|
9. Else, if type is "Float64", then
|
||||||
|
...
|
||||||
|
10. Else,
|
||||||
|
...
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 50 for Element Type type.
|
||||||
|
c. Let intValue be convOp(value).
|
||||||
|
d. If intValue ≥ 0, then
|
||||||
|
...
|
||||||
|
e. Else,
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testTypedArrayConversions(function(TA, value, expected) {
|
||||||
|
var sample = new TA([value]);
|
||||||
|
|
||||||
|
assert.sameValue(sample[0], expected, value + " converts to " + expected);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user