aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-14 19:24:54 +0800
committerGitHub <noreply@github.com>2017-12-14 19:24:54 +0800
commit90313875f75f68fecfc23c6c6f96f921da730301 (patch)
tree15347e8316300fc4316d621e6ddbc85ba68720f8 /test/compress
parent3f18a61532a86f0f52edbb50ca7d81e0869ad7c3 (diff)
downloadtracifyjs-90313875f75f68fecfc23c6c6f96f921da730301.tar.gz
tracifyjs-90313875f75f68fecfc23c6c6f96f921da730301.zip
inline single-use `function` across loop (#2594)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 7e87692d..c4281d5c 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -672,3 +672,78 @@ empty_body: {
}
}
}
+
+inline_loop_1: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f() {
+ return x();
+ }
+ for (;;) f();
+ }
+ expect: {
+ for (;;) x();
+ }
+}
+
+inline_loop_2: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ for (;;) f();
+ function f() {
+ return x();
+ }
+ }
+ expect: {
+ for (;;) x();
+ }
+}
+
+inline_loop_3: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var f = function() {
+ return x();
+ };
+ for (;;) f();
+ }
+ expect: {
+ for (;;) x();
+ }
+}
+
+inline_loop_4: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ for (;;) f();
+ var f = function() {
+ return x();
+ };
+ }
+ expect: {
+ for (;;) f();
+ var f = function() {
+ return x();
+ };
+ }
+}