aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-24 01:51:18 +0000
committerGitHub <noreply@github.com>2021-01-24 09:51:18 +0800
commit8bfd891c09edfb54d1b93010487ee68ad64a457c (patch)
tree947c02f460b927b4a0843e3f0955a5636621a067 /test
parentef9f7ca3e7c7f71df440645f782b3a7da4646d9b (diff)
downloadtracifyjs-8bfd891c09edfb54d1b93010487ee68ad64a457c.tar.gz
tracifyjs-8bfd891c09edfb54d1b93010487ee68ad64a457c.zip
support BigInt literals (#4583)
Diffstat (limited to 'test')
-rw-r--r--test/compress/arrays.js5
-rw-r--r--test/compress/bigint.js46
-rw-r--r--test/compress/issue-269.js2
-rw-r--r--test/compress/numbers.js2
-rw-r--r--test/ufuzz/index.js7
5 files changed, 58 insertions, 4 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js
index 9569c4fa..fff7e9b6 100644
--- a/test/compress/arrays.js
+++ b/test/compress/arrays.js
@@ -13,9 +13,10 @@ holes_and_undefined: {
}
}
-constant_join: {
+constant_join_1: {
options = {
evaluate: true,
+ side_effects: true,
strings: true,
unsafe: true,
}
@@ -57,7 +58,7 @@ constant_join: {
var c5 = [ boo() + bar() + "foo", 1, 2, 3, "bar", bar() + "foo" ].join();
var c6 = [ "1,2,,,foo,bar", baz() ].join();
var d = "foo-3bar-baz";
- var e = [].join(foo + bar);
+ var e = (foo, bar, "");
var f = "";
var g = "";
}
diff --git a/test/compress/bigint.js b/test/compress/bigint.js
new file mode 100644
index 00000000..7ee225ce
--- /dev/null
+++ b/test/compress/bigint.js
@@ -0,0 +1,46 @@
+arithmetic: {
+ input: {
+ console.log(((1n + 0x2n) * (0o3n - -4n)) >> (5n - 6n));
+ }
+ expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);"
+ expect_stdout: "42n"
+ node_version: ">=10"
+}
+
+minus_dot: {
+ input: {
+ console.log(typeof -42n.toString(), typeof (-42n).toString());
+ }
+ expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());"
+ expect_stdout: "number string"
+ node_version: ">=10"
+}
+
+evaluate: {
+ options = {
+ evaluate: true,
+ unsafe: true,
+ }
+ input: {
+ console.log((0xDEAD_BEEFn).toString(16));
+ }
+ expect: {
+ console.log(0xdeadbeefn.toString(16));
+ }
+ expect_stdout: "deadbeef"
+ node_version: ">=10"
+}
+
+Number: {
+ options = {
+ unsafe: true,
+ }
+ input: {
+ console.log(Number(-0xfeed_dead_beef_badn));
+ }
+ expect: {
+ console.log(+("" + -0xfeed_dead_beef_badn));
+ }
+ expect_stdout: "-1148098955808013200"
+ node_version: ">=10"
+}
diff --git a/test/compress/issue-269.js b/test/compress/issue-269.js
index 2adc5017..3e0c4437 100644
--- a/test/compress/issue-269.js
+++ b/test/compress/issue-269.js
@@ -17,7 +17,7 @@ issue_269_1: {
expect: {
var x = {};
console.log(
- x + "", +x, !!x,
+ "" + x, +("" + x), !!x,
"", 0, false
);
}
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index 5a7000cd..994cd5cf 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -338,7 +338,7 @@ evaluate_3: {
console.log(1 + Number(x) + 2);
}
expect: {
- console.log(+x + 3);
+ console.log(+("" + x) + 3);
}
}
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 0a6de2a3..a9676fc0 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -134,6 +134,7 @@ var SUPPORT = function(matrix) {
}({
arrow: "a => 0;",
async: "async function f(){}",
+ bigint: "42n",
catch_omit_var: "try {} catch {}",
computed_key: "({[0]: 0});",
const_block: "var a; { const a = 0; }",
@@ -188,6 +189,12 @@ var VALUES = [
'"function"',
"this",
];
+if (SUPPORT.bigint) VALUES = VALUES.concat([
+ "!0o644n",
+ "([3n][0] > 2)",
+ "(-42n).toString()",
+ "Number(0XDEADn << 16n | 0xbeefn)",
+]);
var BINARY_OPS = [
" + ", // spaces needed to disambiguate with ++ cases (could otherwise cause syntax errors)