Debian Codegraph @

js/src/tests/test262/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 description: Bitwise NOT for BigInt object wrappers
5 esid: sec-bitwise-not-operator-runtime-semantics-evaluation
6 info: |
7 Runtime Semantics: Evaluation
8 UnaryExpression : ~ UnaryExpression
9
10 1. Let expr be the result of evaluating UnaryExpression.
11 2. Let oldValue be ? ToNumeric(? GetValue(expr)).
12 3. Let T be Type(oldValue).
13 4. Return ? T::bitwiseNOT(oldValue).
14
15 features: [BigInt, Symbol.toPrimitive]
16 ---*/
17 assert.sameValue(~Object(1n), -2n, 'The value of ~Object(1n) is -2n');
18
19 function err() {
20 throw new Test262Error();
21 }
22
23 assert.sameValue(~{
24 [Symbol.toPrimitive]: function() {
25 return 1n;
26 },
27
28 valueOf: err,
29 toString: err
30 }, -2n, 'The value of ~{[Symbol.toPrimitive]: function() {return 1n;}, valueOf: err, toString: err} is -2n');
31
32 assert.sameValue(~{
33 valueOf: function() {
34 return 1n;
35 },
36
37 toString: err
38 }, -2n, 'The value of ~{valueOf: function() {return 1n;}, toString: err} is -2n');
39
40 assert.sameValue(~{
41 toString: function() {
42 return 1n;
43 }
44 }, -2n, 'The value of ~{toString: function() {return 1n;}} is -2n');
45
46 reportCompare(0, 0);