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