Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / bigint-tonumber.js
blob4d417b919b758bc7c704ca8b2873778b0d7d1d01
1 // Copyright (C) 2018 Valerie Young. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid:  sec-assignment-operators-runtime-semantics-evaluation
5 description: >
6   Return abrupt on BigInt
7 info: |
8   Runtime Semantics: Evaluation
9   AssignmentExpression : LeftHandSideExpression = AssignmentExpression
10   1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then
11   ...
12     f. Perform ? PutValue(lref, rval).
13   ...
15   PutValue ( V, W )
16   ...
17   6. Else if IsPropertyReference(V) is true, then
18     a. If HasPrimitiveBase(V) is true, then
19         i. Assert: In this case, base will never be undefined or null.
20         ii. Set base to ! ToObject(base).
21     b. Let succeeded be ? base.[[Set]](GetReferencedName(V), W, GetThisValue(V)).
22     c. If succeeded is false and IsStrictReference(V) is true, throw a TypeError
23        exception.
24     d. Return.
26   [[Set]] ( P, V, Receiver )
27   When the [[Set]] internal method of an Integer-Indexed exotic object O is
28   called with property key P, value V, and ECMAScript language value Receiver,
29   the following steps are taken:
30   1. Assert: IsPropertyKey(P) is true.
31   2. If Type(P) is String, then
32     a. Let numericIndex be ! CanonicalNumericIndexString(P).
33     b. If numericIndex is not undefined, then
34        i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
36   IntegerIndexedElementSet ( O, index, value )
37   5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
38      let numValue be ? ToBigInt(value).
39   6. Otherwise, let numValue be ? ToNumber(value).
40   ...
42   ToNumber ( argument )
43   The abstract operation ToNumber converts argument to a value of type Number
44   according to:
46   Number Conversion
47     Argument Type: BigInt
48     Result: Throw a TypeError Exception
50 includes: [testTypedArray.js]
51 features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
52 ---*/
53 testWithTypedArrayConstructors(function(TA) {
54   var typedArray = new TA(1);
56   assert.throws(TypeError, function() {
57     typedArray[0] = 1n;
58   });
59 });
61 reportCompare(0, 0);