Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / conversion-operation.js
blob786b0c4becf4b7e3b03ec3d011309d7a7ec6ae76
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
6 description: >
7   Verify conversion after setting value
8 info: |
9   9.4.5.5 [[Set]] ( P, V, Receiver)
11   ...
12   2. If Type(P) is String, then
13     ...
14     b. If numericIndex is not undefined, then
15       i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
16       ii. Return true.
17   ...
19   IntegerIndexedElementSet ( O, index, value )
21   Assert: O is an Integer-Indexed exotic object.
22   If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
23   Otherwise, let numValue be ? ToNumber(value).
24   Let buffer be O.[[ViewedArrayBuffer]].
25   If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
26     Let offset be O.[[ByteOffset]].
27     Let arrayTypeName be the String value of O.[[TypedArrayName]].
28     Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
29     Let indexedPosition be (ℝ(index) × elementSize) + offset.
30     Let elementType be the Element Type value in Table 62 for arrayTypeName.
31     Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
32   Return NormalCompletion(undefined).
34   24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
35   isLittleEndian ] )
37   ...
38   8. If type is "Float32", then
39     ...
40   9. Else, if type is "Float64", then
41     ...
42   10. Else,
43     ...
44     b. Let convOp be the abstract operation named in the Conversion Operation
45     column in Table 50 for Element Type type.
46     c. Let intValue be convOp(value).
47     d. If intValue ≥ 0, then
48       ...
49     e. Else,
50       ...
51 includes: [byteConversionValues.js, testTypedArray.js]
52 features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
53 ---*/
55 testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
56   var sample = new TA([initial]);
58   sample[0] = value;
60   assert.sameValue(sample[0], expected, 'The value of sample[0] is expected to equal the value of expected');
61 });
63 reportCompare(0, 0);