aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress/loops.js113
1 files changed, 113 insertions, 0 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js
index 3538c221..a6ebd359 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -492,3 +492,116 @@ dead_code_condition: {
}
expect_stdout: "1"
}
+
+issue_2740_1: {
+ options = {
+ dead_code: true,
+ loops: true,
+ }
+ input: {
+ for (; ; ) break;
+ for (a(); ; ) break;
+ for (; b(); ) break;
+ for (c(); d(); ) break;
+ for (; ; e()) break;
+ for (f(); ; g()) break;
+ for (; h(); i()) break;
+ for (j(); k(); l()) break;
+ }
+ expect: {
+ a();
+ b();
+ c();
+ d();
+ f();
+ h();
+ j();
+ k();
+ }
+}
+
+issue_2740_2: {
+ options = {
+ dead_code: true,
+ loops: true,
+ passes: 2,
+ }
+ input: {
+ L1: while (x()) {
+ break L1;
+ }
+ }
+ expect: {
+ x();
+ }
+}
+
+issue_2740_3: {
+ options = {
+ dead_code: true,
+ loops: true,
+ }
+ input: {
+ L1: for (var x = 0; x < 3; x++) {
+ L2: for (var y = 0; y < 2; y++) {
+ break L1;
+ }
+ }
+ console.log(x, y);
+ }
+ expect: {
+ L1: for (var x = 0; x < 3; x++)
+ for (var y = 0; y < 2; y++)
+ break L1;
+ console.log(x, y);
+ }
+ expect_stdout: "0 0"
+}
+
+issue_2740_4: {
+ options = {
+ dead_code: true,
+ loops: true,
+ passes: 2,
+ }
+ input: {
+ L1: for (var x = 0; x < 3; x++) {
+ L2: for (var y = 0; y < 2; y++) {
+ break L2;
+ }
+ }
+ console.log(x, y);
+ }
+ expect: {
+ for (var x = 0; x < 3; x++) {
+ var y = 0;
+ y < 2;
+ }
+ console.log(x, y);
+ }
+ expect_stdout: "3 0"
+}
+
+issue_2740_5: {
+ options = {
+ dead_code: true,
+ loops: true,
+ passes: 2,
+ }
+ input: {
+ L1: for (var x = 0; x < 3; x++) {
+ break L1;
+ L2: for (var y = 0; y < 2; y++) {
+ break L2;
+ }
+ }
+ console.log(x, y);
+ }
+ expect: {
+ var x = 0;
+ x < 3;
+ var y;
+ console.log(x,y);
+ }
+ expect_stdout: "0 undefined"
+}