aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-04-22 03:58:50 +0100
committerGitHub <noreply@github.com>2021-04-22 10:58:50 +0800
commitbddb5a01026e8295f9271f7d787e70937acba9d8 (patch)
treef1bc1ed5ea92a15b9cab8b6aaf485a8608a997d6 /test
parent3c161a666259389f96f9aa88a5b6d4e7579d50a4 (diff)
downloadtracifyjs-bddb5a01026e8295f9271f7d787e70937acba9d8.tar.gz
tracifyjs-bddb5a01026e8295f9271f7d787e70937acba9d8.zip
enhance `unused` (#4858)
Diffstat (limited to 'test')
-rw-r--r--test/compress/classes.js20
-rw-r--r--test/compress/functions.js17
-rw-r--r--test/ufuzz/index.js4
3 files changed, 39 insertions, 2 deletions
diff --git a/test/compress/classes.js b/test/compress/classes.js
index ca9ddfdd..e8bff752 100644
--- a/test/compress/classes.js
+++ b/test/compress/classes.js
@@ -1541,3 +1541,23 @@ issue_4848: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+drop_unused_self_reference: {
+ options = {
+ pure_getters: "strict",
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ class A {}
+ (A.p = A).q = console.log("PASS");
+ }
+ expect: {
+ "use strict";
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 4d4cb66d..3d19f497 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -6021,3 +6021,20 @@ issue_4823: {
}
expect_stdout: "function"
}
+
+drop_unused_self_reference: {
+ options = {
+ pure_getters: "strict",
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f() {}
+ (f.p = f).q = console.log("PASS");
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 69760b22..7210c6b2 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -1796,7 +1796,7 @@ function createClassLiteral(recurmax, stmtDepth, canThrow, name) {
if (SUPPORT.class_field && rng(2)) {
s += internal || createObjectKey(recurmax, stmtDepth, canThrow);
if (rng(5)) {
- async = bug_async_class_await && fixed;
+ async = bug_async_class_await && fixed && 0;
generator = false;
s += " = " + createExpression(recurmax, NO_COMMA, stmtDepth, fixed ? canThrow : CANNOT_THROW);
generator = save_generator;
@@ -2000,7 +2000,7 @@ function isBannedKeyword(name) {
case "arguments":
return in_class;
case "await":
- return async;
+ return async !== false;
case "yield":
return generator || in_class;
}