aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-04 20:49:37 +0000
committerGitHub <noreply@github.com>2021-02-05 04:49:37 +0800
commitda24dfb59ea9c67d98f39daab4299b75c15978ea (patch)
tree1bfe2aa0bb32ed5a577327a1476f95d0014af877 /test/compress
parenta2f27c7640fee2c981b49ee484a37e1721622bb3 (diff)
downloadtracifyjs-da24dfb59ea9c67d98f39daab4299b75c15978ea.tar.gz
tracifyjs-da24dfb59ea9c67d98f39daab4299b75c15978ea.zip
fix corner cases with function inlining (#4613)
fixes #4612
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js124
1 files changed, 124 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index e0a4ee72..5de05f61 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -5283,3 +5283,127 @@ issue_4471: {
"PASS",
]
}
+
+issue_4612_1: {
+ options = {
+ evaluate: true,
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ console.log(function() {
+ function f() {
+ return g();
+ }
+ function g(a) {
+ return a || f();
+ }
+ return g("PASS");
+ }());
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
+
+issue_4612_2: {
+ options = {
+ evaluate: true,
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ console.log(function() {
+ function fn() {
+ return h();
+ }
+ function g() {
+ return fn();
+ }
+ function h(a) {
+ return a || fn();
+ }
+ return h("PASS");
+ }());
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
+
+issue_4612_3: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ }
+ input: {
+ console.log(typeof function() {
+ return g();
+ function f() {
+ return g;
+ }
+ function g() {
+ {
+ return f;
+ }
+ }
+ }());
+ }
+ expect: {
+ console.log(typeof function() {
+ return g();
+ function f() {
+ return g;
+ }
+ function g() {
+ return f;
+ }
+ }());
+ }
+ expect_stdout: "function"
+}
+
+issue_4612_4: {
+ options = {
+ booleans: true,
+ evaluate: true,
+ reduce_vars: true,
+ }
+ input: {
+ console.log(function() {
+ function f() {
+ return h();
+ }
+ function g() {
+ {
+ return h();
+ }
+ }
+ function h() {
+ {
+ return g();
+ }
+ }
+ }());
+ }
+ expect: {
+ console.log(function() {
+ function f() {
+ return h();
+ }
+ function g() {
+ return h();
+ }
+ function h() {
+ return g();
+ }
+ }());
+ }
+ expect_stdout: "undefined"
+}