aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-08 04:38:53 +0000
committerGitHub <noreply@github.com>2021-03-08 12:38:53 +0800
commit077512d1515d9fbd4e19bce79be75a09df8d5619 (patch)
tree43f7a322bb8db5a2fb70266c65e67654013dc0ba /test
parente4848a7f5a819f78515c487e64d46de3c3d2d743 (diff)
downloadtracifyjs-077512d1515d9fbd4e19bce79be75a09df8d5619.tar.gz
tracifyjs-077512d1515d9fbd4e19bce79be75a09df8d5619.zip
fix corner case in `inline` (#4754)
fixes #4753
Diffstat (limited to 'test')
-rw-r--r--test/compress/functions.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 856dbcea..682b5844 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -5771,3 +5771,64 @@ new_target: {
expect_stdout: "function undefined"
node_version: ">=6"
}
+
+issue_4753_1: {
+ options = {
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ for (var i in [ 1, 2 ])
+ (function() {
+ function f() {}
+ f && console.log(f.p ^= 42);
+ })();
+ }
+ expect: {
+ for (var i in [ 1, 2 ])
+ f = function() {},
+ void (f && console.log(f.p ^= 42));
+ var f;
+ }
+ expect_stdout: [
+ "42",
+ "42",
+ ]
+}
+
+issue_4753_2: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ do {
+ (function() {
+ var a = f();
+ function f() {
+ return "PASS";
+ }
+ f;
+ function g() {
+ console.log(a);
+ }
+ g();
+ })();
+ } while (0);
+ }
+ expect: {
+ do {
+ f = function() {
+ return "PASS";
+ },
+ a = void 0,
+ a = f(),
+ console.log(a);
+ } while (0);
+ var f, a;
+ }
+ expect_stdout: "PASS"
+}