Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/bitwise-not/bigint-non-primitive.js

raw
1 // Copyright (C) 2017 Josh Wolfe. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Bitwise NOT for BigInt object wrappers
6 esid: sec-bitwise-not-operator-runtime-semantics-evaluation
7 info: |
8 Runtime Semantics: Evaluation
9 UnaryExpression : ~ UnaryExpression
10
11 1. Let expr be the result of evaluating UnaryExpression.
12 2. Let oldValue be ? ToNumeric(? GetValue(expr)).
13 3. Let T be Type(oldValue).
14 4. Return ? T::bitwiseNOT(oldValue).
15
16 features: [BigInt, Symbol.toPrimitive]
17 ---*/
18
19 assert.sameValue(~Object(1n), -2n, "~Object(1n) === -2n");
20
21 function err() {
22 throw new Test262Error();
23 }
24
25 assert.sameValue(
26 ~{[Symbol.toPrimitive]: function() { return 1n; }, valueOf: err, toString: err}, -2n,
27 "primitive from @@toPrimitive");
28 assert.sameValue(
29 ~{valueOf: function() { return 1n; }, toString: err}, -2n,
30 "primitive from {}.valueOf");
31 assert.sameValue(
32 ~{toString: function() { return 1n; }}, -2n,
33 "primitive from {}.toString");