aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-06-15 11:27:55 +0100
committerGitHub <noreply@github.com>2021-06-15 18:27:55 +0800
commitbf76e357723daa4fc00004a10b2b3de82a2bf33e (patch)
tree02bfcdaf727adf43a6abf70b3fb92f08f547df96 /test
parentac1262dc9708db36721349f1d3d03fc2113f2add (diff)
downloadtracifyjs-bf76e357723daa4fc00004a10b2b3de82a2bf33e.tar.gz
tracifyjs-bf76e357723daa4fc00004a10b2b3de82a2bf33e.zip
fix corner case in `switches` (#5009)
fixes #5008
Diffstat (limited to 'test')
-rw-r--r--test/compress/switches.js115
1 files changed, 115 insertions, 0 deletions
diff --git a/test/compress/switches.js b/test/compress/switches.js
index 955fd68a..cbaa0644 100644
--- a/test/compress/switches.js
+++ b/test/compress/switches.js
@@ -1441,3 +1441,118 @@ issue_4059: {
}
expect_stdout: "PASS"
}
+
+issue_5008_1: {
+ options = {
+ dead_code: true,
+ evaluate: true,
+ reduce_vars: true,
+ switches: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(function f() {
+ switch (f) {
+ case f:
+ return "PASS";
+ default:
+ return "FAIL";
+ }
+ }());
+ }
+ expect: {
+ console.log(function f() {
+ switch (f) {
+ case f:
+ return "PASS";
+ }
+ }());
+ }
+ expect_stdout: "PASS"
+}
+
+issue_5008_2: {
+ options = {
+ dead_code: true,
+ evaluate: true,
+ reduce_vars: true,
+ switches: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ default:
+ return "FAIL";
+ }
+ }([]));
+ }
+ expect: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ }
+ }([]));
+ }
+ expect_stdout: "PASS"
+}
+
+issue_5008_3: {
+ options = {
+ dead_code: true,
+ evaluate: true,
+ reduce_vars: true,
+ switches: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ default:
+ return "FAIL";
+ }
+ }({}));
+ }
+ expect: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ }
+ }({}));
+ }
+ expect_stdout: "PASS"
+}
+
+issue_5008_4: {
+ options = {
+ dead_code: true,
+ evaluate: true,
+ reduce_vars: true,
+ switches: true,
+ }
+ input: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ default:
+ return "FAIL";
+ }
+ }(/foo/));
+ }
+ expect: {
+ console.log(function(a) {
+ switch (a) {
+ case a:
+ return "PASS";
+ }
+ }(/foo/));
+ }
+ expect_stdout: "PASS"
+}