Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: node_modules/vulcanize/node_modules/uglify-js/test/compress/loops.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/uglify-js/test/compress/loops.js
diff --git a/node_modules/vulcanize/node_modules/uglify-js/test/compress/loops.js b/node_modules/vulcanize/node_modules/uglify-js/test/compress/loops.js
new file mode 100644
index 0000000000000000000000000000000000000000..cdf1f045d9e05a1da801b373b560be49a071a508
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/uglify-js/test/compress/loops.js
@@ -0,0 +1,123 @@
+while_becomes_for: {
+ options = { loops: true };
+ input: {
+ while (foo()) bar();
+ }
+ expect: {
+ for (; foo(); ) bar();
+ }
+}
+
+drop_if_break_1: {
+ options = { loops: true };
+ input: {
+ for (;;)
+ if (foo()) break;
+ }
+ expect: {
+ for (; !foo(););
+ }
+}
+
+drop_if_break_2: {
+ options = { loops: true };
+ input: {
+ for (;bar();)
+ if (foo()) break;
+ }
+ expect: {
+ for (; bar() && !foo(););
+ }
+}
+
+drop_if_break_3: {
+ options = { loops: true };
+ input: {
+ for (;bar();) {
+ if (foo()) break;
+ stuff1();
+ stuff2();
+ }
+ }
+ expect: {
+ for (; bar() && !foo();) {
+ stuff1();
+ stuff2();
+ }
+ }
+}
+
+drop_if_break_4: {
+ options = { loops: true, sequences: true };
+ input: {
+ for (;bar();) {
+ x();
+ y();
+ if (foo()) break;
+ z();
+ k();
+ }
+ }
+ expect: {
+ for (; bar() && (x(), y(), !foo());) z(), k();
+ }
+}
+
+drop_if_else_break_1: {
+ options = { loops: true };
+ input: {
+ for (;;) if (foo()) bar(); else break;
+ }
+ expect: {
+ for (; foo(); ) bar();
+ }
+}
+
+drop_if_else_break_2: {
+ options = { loops: true };
+ input: {
+ for (;bar();) {
+ if (foo()) baz();
+ else break;
+ }
+ }
+ expect: {
+ for (; bar() && foo();) baz();
+ }
+}
+
+drop_if_else_break_3: {
+ options = { loops: true };
+ input: {
+ for (;bar();) {
+ if (foo()) baz();
+ else break;
+ stuff1();
+ stuff2();
+ }
+ }
+ expect: {
+ for (; bar() && foo();) {
+ baz();
+ stuff1();
+ stuff2();
+ }
+ }
+}
+
+drop_if_else_break_4: {
+ options = { loops: true, sequences: true };
+ input: {
+ for (;bar();) {
+ x();
+ y();
+ if (foo()) baz();
+ else break;
+ z();
+ k();
+ }
+ }
+ expect: {
+ for (; bar() && (x(), y(), foo());) baz(), z(), k();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698