aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-05 01:26:59 +0100
committerGitHub <noreply@github.com>2020-10-05 08:26:59 +0800
commit813ac3ba9663d4123043aa823da59b6c3387f30f (patch)
treea2e8f0fb11a559f46b9740b81eaad42a02b42041 /test/compress
parent220dc95c0d212ad4f3b97fcd937c4370ae5345dd (diff)
downloadtracifyjs-813ac3ba9663d4123043aa823da59b6c3387f30f.tar.gz
tracifyjs-813ac3ba9663d4123043aa823da59b6c3387f30f.zip
enhance `loops` (#4180)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/loops.js46
1 files changed, 42 insertions, 4 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js
index cbc1166f..b8d351ad 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -201,7 +201,7 @@ evaluate: {
}
}
-issue_1532: {
+issue_1532_1: {
options = {
evaluate: true,
loops: true,
@@ -210,18 +210,56 @@ issue_1532: {
function f(x, y) {
do {
if (x) break;
- foo();
+ console.log(y);
} while (false);
}
+ f(null, "PASS");
+ f(42, "FAIL");
}
expect: {
function f(x, y) {
+ for (; !x && (console.log(y), false););
+ }
+ f(null, "PASS");
+ f(42, "FAIL");
+ }
+ expect_stdout: "PASS"
+}
+
+issue_1532_2: {
+ options = {
+ evaluate: true,
+ loops: true,
+ }
+ input: {
+ function f(x, y) {
do {
- if (x) break;
- foo();
+ if (x) {
+ console.log(x);
+ break;
+ }
+ console.log(y);
} while (false);
}
+ f(null, "PASS");
+ f(42, "FAIL");
+ }
+ expect: {
+ function f(x, y) {
+ do {
+ if (x) {
+ console.log(x);
+ break;
+ }
+ } while (console.log(y), false);
+ }
+ f(null, "PASS");
+ f(42, "FAIL");
}
+ expect_stdout: [
+ "PASS",
+ "42",
+ ]
}
issue_186: {