aboutsummaryrefslogtreecommitdiff
path: root/test/compress/booleans.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-06-23 00:42:57 +0100
committerGitHub <noreply@github.com>2021-06-23 07:42:57 +0800
commit980dbde171d47c36028355a4cbd4f6f0e7700976 (patch)
tree612fd701844a01ba97c7ee2b0e984d5dcdf18e52 /test/compress/booleans.js
parent8b05677c15308923a76a6c769dc628a93901556d (diff)
downloadtracifyjs-980dbde171d47c36028355a4cbd4f6f0e7700976.tar.gz
tracifyjs-980dbde171d47c36028355a4cbd4f6f0e7700976.zip
fix corner cases in `booleans` (#5029)
fixes #5028
Diffstat (limited to 'test/compress/booleans.js')
-rw-r--r--test/compress/booleans.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/compress/booleans.js b/test/compress/booleans.js
index cd860f96..0926c0e4 100644
--- a/test/compress/booleans.js
+++ b/test/compress/booleans.js
@@ -558,3 +558,79 @@ issue_4374: {
}
expect_stdout: "0"
}
+
+issue_5028_1: {
+ options = {
+ booleans: true,
+ conditionals: true,
+ }
+ input: {
+ var a = 1;
+ console.log(function() {
+ return a-- ? a-- ? "FAIL 1" : "PASS" : "FAIL 2";
+ }());
+ }
+ expect: {
+ var a = 1;
+ console.log(function() {
+ return a-- ? a-- ? "FAIL 1" : "PASS" : "FAIL 2";
+ }());
+ }
+ expect_stdout: "PASS"
+}
+
+issue_5028_2: {
+ options = {
+ booleans: true,
+ conditionals: true,
+ dead_code: true,
+ if_return: true,
+ }
+ input: {
+ var a = 1;
+ (function() {
+ if (a--)
+ if (a--)
+ a = "FAIL";
+ else
+ return;
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = 1;
+ (function() {
+ a-- && a-- && (a = "FAIL");
+ })();
+ console.log(a);
+ }
+ expect_stdout: "-1"
+}
+
+issue_5028_3: {
+ options = {
+ booleans: true,
+ conditionals: true,
+ evaluate: true,
+ if_return: true,
+ }
+ input: {
+ var a = 1;
+ (function() {
+ if (a--)
+ if (a--)
+ a = "FAIL";
+ else
+ return;
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = 1;
+ (function() {
+ a-- && a-- && (a = "FAIL");
+ })();
+ console.log(a);
+ }
+ expect_stdout: "-1"
+}