aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-10 05:47:10 +0800
committerGitHub <noreply@github.com>2017-11-10 05:47:10 +0800
commit94525d859f5db559366f96b646aca84438b0f982 (patch)
treefc9aa27f6e2e8dea8c441308d2ac51f1c4586ba9 /test/compress
parent1127a2caf305ad1df370c34faf7283e53423cc10 (diff)
downloadtracifyjs-94525d859f5db559366f96b646aca84438b0f982.tar.gz
tracifyjs-94525d859f5db559366f96b646aca84438b0f982.zip
fix object literal tracing in `reduce_vars` (#2461)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/reduce_vars.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index d7c5601a..e84ac6cb 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -286,6 +286,7 @@ unsafe_evaluate_modified: {
function inc() { this.p++; }
console.log(function(){ var o={p:6}; inc.call(o); console.log(o.p); return o.p; }());
console.log(function(){ var o={p:7}; console.log([o][0].p++); return o.p; }());
+ console.log(function(){ var o={p:8}; console.log({q:o}.q.p++); return o.p; }());
}
expect: {
console.log(function(){ var o={p:1}; o.p++; console.log(o.p); return o.p; }());
@@ -296,6 +297,7 @@ unsafe_evaluate_modified: {
function inc() { this.p++; }
console.log(function(){ var o={p:6}; inc.call(o); console.log(o.p); return o.p; }());
console.log(function(){ var o={p:7}; console.log([o][0].p++); return o.p; }());
+ console.log(function(){ var o={p:8}; console.log({q:o}.q.p++); return o.p; }());
}
expect_stdout: true
}
@@ -3269,7 +3271,7 @@ const_expr_2: {
expect_stdout: "2 2"
}
-escaped_prop: {
+escaped_prop_1: {
options = {
collapse_vars: true,
evaluate: true,
@@ -3298,6 +3300,40 @@ escaped_prop: {
expect_stdout: "2"
}
+escaped_prop_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a;
+ function f(b) {
+ if (a) console.log(a === b.c);
+ a = b.c;
+ }
+ function g() {}
+ function h() {
+ f({ c: g });
+ }
+ h();
+ h();
+ }
+ expect: {
+ var a;
+ function g() {}
+ function h() {
+ (function(b) {
+ if (a) console.log(a === b.c);
+ a = b.c;
+ })({ c: g });
+ }
+ h();
+ h();
+ }
+ expect_stdout: "true"
+}
+
issue_2420_1: {
options = {
reduce_vars: true,