Invalid flags in a RegExp literal should be an early SyntaxError
[WebKit-https.git] / JSTests / stress / big-int-bitwise-or-wrapped-value.js
1 //@ runBigIntEnabled
2
3 assert = {
4     sameValue: function (input, expected, message) {
5         if (input !== expected)
6             throw new Error(message);
7     }
8 };
9
10 function testBitOr(x, y, z, message) {
11     assert.sameValue(x | y, z, message);
12     assert.sameValue(y | x, z, message);
13 }
14
15 testBitOr(Object(0b10n), 0b01n, 0b11n, "ToPrimitive: unbox object with internal slot");
16
17 let o = {
18     [Symbol.toPrimitive]: function() {
19         return 0b10n;
20     }
21 };
22 testBitOr(o, 0b01n, 0b11n, "ToPrimitive: @@toPrimitive");
23
24 o = {
25     valueOf: function() {
26         return 0b10n;
27     }
28 };
29 testBitOr(o, 0b01n, 0b11n, "ToPrimitive: valueOf");
30
31 o = {
32     toString: function() {
33         return 0b10n;
34     }
35 }
36 testBitOr(o, 0b01n, 0b11n, "ToPrimitive: toString");
37
38 // BigInt with length > 1
39
40 testBitOr(Object(0b1111000000000000000000000000000000000000000000000000000000000000000n), 0b1000000000000000000000000000000000000000000000000000000000000001111n, 0b1111000000000000000000000000000000000000000000000000000000000001111n, "ToPrimitive: unbox object with internal slot");
41
42 o = {
43     [Symbol.toPrimitive]: function() {
44         return 0b1111000000000000000000000000000000000000000000000000000000000000000n;
45     }
46 };
47 testBitOr(o, 0b1000000000000000000000000000000000000000000000000000000000000001111n, 0b1111000000000000000000000000000000000000000000000000000000000001111n, "ToPrimitive: @@toPrimitive");
48
49 o = {
50     valueOf: function() {
51         return 0b1111000000000000000000000000000000000000000000000000000000000000000n;
52     }
53 };
54 testBitOr(o, 0b1000000000000000000000000000000000000000000000000000000000000001111n, 0b1111000000000000000000000000000000000000000000000000000000000001111n, "ToPrimitive: valueOf");
55
56 o = {
57     toString: function() {
58         return 0b1111000000000000000000000000000000000000000000000000000000000000000n;
59     }
60 }
61 testBitOr(o, 0b1000000000000000000000000000000000000000000000000000000000000001111n, 0b1111000000000000000000000000000000000000000000000000000000000001111n, "ToPrimitive: toString");
62