Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/bitwise-or/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 OR 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 ...
13 10. If @ is |, return T::bitwiseOR(lnum, rnum).
14
15 features: [BigInt]
16 ---*/
17
18 assert.sameValue(Object(0b101n) | 0b011n, 0b111n, "Object(0b101n) | 0b011n === 0b111n");
19 assert.sameValue(0b011n | Object(0b101n), 0b111n, "0b011n | Object(0b101n) === 0b111n");
20 assert.sameValue(Object(0b101n) | Object(0b011n), 0b111n, "Object(0b101n) | Object(0b011n) === 0b111n");
21
22 function err() {
23 throw new Test262Error();
24 }
25
26 assert.sameValue(
27 {[Symbol.toPrimitive]: function() { return 0b101n; }, valueOf: err, toString: err} | 0b011n, 0b111n,
28 "primitive from @@toPrimitive");
29 assert.sameValue(
30 0b011n | {[Symbol.toPrimitive]: function() { return 0b101n; }, valueOf: err, toString: err}, 0b111n,
31 "primitive from @@toPrimitive");
32 assert.sameValue(
33 {valueOf: function() { return 0b101n; }, toString: err} | 0b011n, 0b111n,
34 "primitive from {}.valueOf");
35 assert.sameValue(
36 0b011n | {valueOf: function() { return 0b101n; }, toString: err}, 0b111n,
37 "primitive from {}.valueOf");
38 assert.sameValue(
39 {toString: function() { return 0b101n; }} | 0b011n, 0b111n,
40 "primitive from {}.toString");
41 assert.sameValue(
42 0b011n | {toString: function() { return 0b101n; }}, 0b111n,
43 "primitive from {}.toString");