Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/bitwise-and/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 AND for BigInt non-primitive values
6 esid: sec-binary-bitwise-operators-runtime-semantics-evaluation
7 info: |
8 5. Let lnum be ? ToNumeric(lval).
9 6. Let rnum be ? ToNumeric(rval).
10 ...
11 8. Let T be Type(lnum).
12 9. If @ is &, return T::bitwiseAND(lnum, rnum).
13
14 features: [BigInt]
15 ---*/
16
17 assert.sameValue(Object(0b101n) & 0b011n, 0b001n, "Object(0b101n) & 0b011n === 0b001n");
18 assert.sameValue(0b011n & Object(0b101n), 0b001n, "0b011n & Object(0b101n) === 0b001n");
19 assert.sameValue(Object(0b101n) & Object(0b011n), 0b001n, "Object(0b101n) & Object(0b011n) === 0b001n");
20
21 function err() {
22 throw new Test262Error();
23 }
24
25 assert.sameValue(
26 {[Symbol.toPrimitive]: function() { return 0b101n; }, valueOf: err, toString: err} & 0b011n, 0b001n,
27 "primitive from @@toPrimitive");
28 assert.sameValue(
29 0b011n & {[Symbol.toPrimitive]: function() { return 0b101n; }, valueOf: err, toString: err}, 0b001n,
30 "primitive from @@toPrimitive");
31 assert.sameValue(
32 {valueOf: function() { return 0b101n; }, toString: err} & 0b011n, 0b001n,
33 "primitive from {}.valueOf");
34 assert.sameValue(
35 0b011n & {valueOf: function() { return 0b101n; }, toString: err}, 0b001n,
36 "primitive from {}.valueOf");
37 assert.sameValue(
38 {toString: function() { return 0b101n; }} & 0b011n, 0b001n,
39 "primitive from {}.toString");
40 assert.sameValue(
41 0b011n & {toString: function() { return 0b101n; }}, 0b001n,
42 "primitive from {}.toString");