[ARM,MIPS] Skip slow tests
[WebKit-https.git] / JSTests / stress / big-int-less-than-or-equal-general.js
1 //@ runBigIntEnabled
2
3 // Copyright (C) 2017 Josh Wolfe. All rights reserved.
4 // Copyright (C) 2017 Robin Templeton. All rights reserved.
5 // Copyright (C) 2018 Igalia, S.L. All rights reserved.
6 // This code is governed by the BSD license found in the LICENSE file.
7
8 function assert(v, e, m) {
9     if (v !== e)
10         throw new Error(m);
11 }
12
13 assert(0n <= 0n, true, "0n <= 0n");
14 assert(1n <= 1n, true, "1n <= 1n");
15 assert(BigInt("-1") <= BigInt("-1"), true, "-1n <= -1n");
16 assert(0n <= BigInt("-0"), true, "0n <= -0n");
17 assert(BigInt("-0") <= 0n, true, "-0n <= 0n");
18 assert(0n <= 1n, true, "0n <= 1n");
19 assert(1n <= 0n, false, "1n <= 0n");
20 assert(0n <= BigInt("-1"), false, "0n <= -1n");
21 assert(BigInt("-1") <= 0n, true, "-1n <= 0n");
22 assert(1n <= BigInt("-1"), false, "1n <= -1n");
23 assert(BigInt("-1") <= 1n, true, "-1n <= 1n");
24 assert(0x1fffffffffffff01n <= 0x1fffffffffffff02n, true, "0x1fffffffffffff01n <= 0x1fffffffffffff02n");
25 assert(0x1fffffffffffff02n <= 0x1fffffffffffff01n, false, "0x1fffffffffffff02n <= 0x1fffffffffffff01n");
26 assert(BigInt("-2305843009213693697") <= BigInt("-2305843009213693698"), false, "-2305843009213693697n <= -2305843009213693698n");
27 assert(BigInt("-2305843009213693698") <= BigInt("-2305843009213693697"), true, "-2305843009213693698n <= -2305843009213693697n");
28 assert(0x10000000000000000n <= 0n, false, "0x10000000000000000n <= 0n");
29 assert(0n <= 0x10000000000000000n, true, "0n <= 0x10000000000000000n");
30 assert(0x10000000000000000n <= 1n, false, "0x10000000000000000n <= 1n");
31 assert(1n <= 0x10000000000000000n, true, "1n <= 0x10000000000000000n");
32 assert(0x10000000000000000n <= BigInt("-1"), false, "0x10000000000000000n <= -1n");
33 assert(BigInt("-1") <= 0x10000000000000000n, true, "-1n <= 0x10000000000000000n");
34 assert(0x10000000000000001n <= 0n, false, "0x10000000000000001n <= 0n");
35 assert(0n <= 0x10000000000000001n, true, "0n <= 0x10000000000000001n");
36 assert(BigInt("-18446744073709551616") <= 0n, true, "-18446744073709551616n <= 0n");
37 assert(0n <= BigInt("-18446744073709551616"), false, "0n <= -18446744073709551616n");
38 assert(BigInt("-18446744073709551616") <= 1n, true, "-18446744073709551616n <= 1n");
39 assert(1n <= BigInt("-18446744073709551616"), false, "1n <= -18446744073709551616n");
40 assert(BigInt("-18446744073709551616") <= BigInt("-1"), true, "-18446744073709551616n <= -1n");
41 assert(BigInt("-1") <= BigInt("-18446744073709551616"), false, "-1n <= -18446744073709551616n");
42 assert(BigInt("-18446744073709551617") <= 0n, true, "-18446744073709551617n <= 0n");
43 assert(0n <= BigInt("-18446744073709551617"), false, "0n <= -18446744073709551617n");
44 assert(0x10000000000000000n <= 0x100000000n, false, "0x10000000000000000n <= 0x100000000n");
45 assert(0x100000000n <= 0x10000000000000000n, true, "0x100000000n <= 0x10000000000000000n");
46
47 // BigInt - String
48
49 assert(0n <= "0", true, "0n <= '0'");
50 assert("0" <= 0n, true, "'0' <= 0n");
51 assert(0n <= "1", true, "0n <= '1'");
52 assert("0" <= 1n, true, "'0' <= 1n");
53 assert(1n <= "0", false, "1n <= '0'");
54 assert("1" <= 0n, false, "'1' <= 0n");
55 assert(0n <= "", true, "0n <= ''");
56 assert("" <= 0n, true, "'' <= 0n");
57 assert(0n <= "1", true, "0n <= '1'");
58 assert("" <= 1n, true, "'' <= 1n");
59 assert(1n <= "", false, "1n <= ''");
60 assert("1" <= 0n, false, "'1' <= 0n");
61 assert(1n <= "1", true, "1n <= '1'");
62 assert("1" <= 1n, true, "'1' <= 1n");
63 assert(1n <= "-1", false, "1n <= '-1'");
64 assert("1" <= BigInt("-1"), false, "'1' <= -1n");
65 assert(BigInt("-1") <= "1", true, "-1n <= '1'");
66 assert("-1" <= 1n, true, "'-1' <= 1n");
67 assert(BigInt("-1") <= "-1", true, "-1n <= '-1'");
68 assert("-1" <= BigInt("-1"), true, "'-1' <= -1n");
69 assert(9007199254740993n <= "9007199254740992", false, "9007199254740993n <= '9007199254740992'");
70 assert("9007199254740993" <= 9007199254740992n, false, "'9007199254740993' <= 9007199254740992n");
71 assert(BigInt("-9007199254740992") <= "-9007199254740993", false, "-9007199254740992n <= '-9007199254740993'");
72 assert("-9007199254740992" <= BigInt("-9007199254740993"), false, "'-9007199254740992' <= -9007199254740993n");
73 assert("0x10" <= 3n, false, "'0x10' <= 3n");
74 assert("0x10" <= 2n, false, "'0x10' <= 2n");
75 assert("0x10" <= 1n, false, "'0x10' <= 1n");
76 assert("0o10" <= 7n, false, "'0o10' <= 7n");
77 assert("0o10" <= 8n, true, "'0o10' <= 8n");
78 assert("0o10" <= 9n, true, "'0o10' <= 9n");
79 assert("0b10" <= 3n, true, "'0b10' <= 3n");
80 assert("0b10" <= 2n, true, "'0b10' <= 2n");
81 assert("0b10" <= 1n, false, "'0b10' <= 1n");
82
83 // Invalid String
84
85 assert("b10" <= 2n, false, "'b10' > 2n");
86 assert("bbb10" <= 2n, false, "'bbb10' > 2n");
87
88 // BigInt - Number
89
90 assert(0n <= 0, true, "0n <= 0");
91 assert(0 <= 0n, true, "0 <= 0n");
92 assert(0n <= -0, true, "0n <= -0");
93 assert(-0 <= 0n, true, "-0 <= 0n");
94 assert(0n <= 0.000000000001, true, "0n <= 0.000000000001");
95 assert(0.000000000001 <= 0n, false, "0.000000000001 <= 0n");
96 assert(0n <= 1, true, "0n <= 1");
97 assert(1 <= 0n, false, "1 <= 0n");
98 assert(1n <= 0, false, "1n <= 0");
99 assert(0 <= 1n, true, "0 <= 1n");
100 assert(1n <= 0.999999999999, false, "1n <= 0.999999999999");
101 assert(0.999999999999 <= 1n, true, "0.999999999999 <= 1n");
102 assert(1n <= 1, true, "1n <= 1");
103 assert(1 <= 1n, true, "1 <= 1n");
104 assert(0n <= Number.MIN_VALUE, true, "0n <= Number.MIN_VALUE");
105 assert(Number.MIN_VALUE <= 0n, false, "Number.MIN_VALUE <= 0n");
106 assert(0n <= -Number.MIN_VALUE, false, "0n <= -Number.MIN_VALUE");
107 assert(-Number.MIN_VALUE <= 0n, true, "-Number.MIN_VALUE <= 0n");
108 assert(BigInt("-10") <= Number.MIN_VALUE, true, "-10n <= Number.MIN_VALUE");
109 assert(Number.MIN_VALUE <= BigInt("-10"), false, "Number.MIN_VALUE <= -10n");
110 assert(1n <= Number.MAX_VALUE, true, "1n <= Number.MAX_VALUE");
111 assert(Number.MAX_VALUE <= 1n, false, "Number.MAX_VALUE <= 1n");
112 assert(1n <= -Number.MAX_VALUE, false, "1n <= -Number.MAX_VALUE");
113 assert(-Number.MAX_VALUE <= 1n, true, "-Number.MAX_VALUE <= 1n");
114 assert(0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn <= Number.MAX_VALUE, true, "0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn <= Number.MAX_VALUE");
115 assert(Number.MAX_VALUE <= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, false, "Number.MAX_VALUE <= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn");
116 assert(0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n <= Number.MAX_VALUE, false, "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n <= Number.MAX_VALUE");
117 assert(Number.MAX_VALUE <= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, true, "Number.MAX_VALUE <= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n");
118 assert(1n <= Infinity, true, "1n <= Infinity");
119 assert(Infinity <= 1n, false, "Infinity <= 1n");
120 assert(BigInt("-1") <= Infinity, true, "-1n <= Infinity");
121 assert(Infinity <= BigInt("-1"), false, "Infinity <= -1n");
122 assert(1n <= -Infinity, false, "1n <= -Infinity");
123 assert(-Infinity <= 1n, true, "-Infinity <= 1n");
124 assert(BigInt("-1") <= -Infinity, false, "-1n <= -Infinity");
125 assert(-Infinity <= BigInt("-1"), true, "-Infinity <= -1n");
126 assert(0n <= NaN, false, "0n <= NaN");
127 assert(NaN <= 0n, false, "NaN <= 0n");
128
129 // BigInt - Boolean
130
131 assert(false <= 1n, true, "false <= 1n");
132 assert(1n <= false, false, "1n <= false");
133 assert(false <= 0n, true, "false <= 0n");
134 assert(0n <= false, true, "0n <= false");
135 assert(true <= 1n, true, "true <= 1n");
136 assert(1n <= true, true, "1n <= true");
137 assert(true <= 2n, true, "true <= 2n");
138 assert(2n <= true, false, "2n <= true");
139
140 // BigInt - Symbol
141
142 try {
143     1n <= Symbol("1");
144     assert(false, true, "Comparison with Symbol shoud throw TypeError, but executed without exception");
145 } catch(e) {
146     assert(e instanceof TypeError, true, "Comparison with Symbol shoud throw TypeError, but throwed something else");
147 }
148