aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-03-31 15:03:46 +0900
committerGitHub <noreply@github.com>2018-03-31 15:03:46 +0900
commit07f64d4050cd28cf2a837d30ce2938fa9628ff57 (patch)
treea6d67da64a31097e6f5ee0715359be99889f9b45 /test/compress/reduce_vars.js
parent6982a0554c875c55de7dfddd71f29d3b765d3979 (diff)
downloadtracifyjs-07f64d4050cd28cf2a837d30ce2938fa9628ff57.tar.gz
tracifyjs-07f64d4050cd28cf2a837d30ce2938fa9628ff57.zip
fix escape analysis on `AST_New` (#3043)
fixes #3042
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 3d11ba42..59a99b9c 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5582,3 +5582,75 @@ issue_2992: {
}
expect_stdout: "PASS"
}
+
+issue_3042_1: {
+ options = {
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f() {}
+ var a = [ 1, 2 ].map(function() {
+ return new f();
+ });
+ console.log(a[0].constructor === a[1].constructor);
+ }
+ expect: {
+ function f() {}
+ var a = [ 1, 2 ].map(function() {
+ return new f();
+ });
+ console.log(a[0].constructor === a[1].constructor);
+ }
+ expect_stdout: "true"
+}
+
+issue_3042_2: {
+ options = {
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function Foo() {
+ this.isFoo = function(o) {
+ return o instanceof Foo;
+ };
+ }
+ function FooCollection() {
+ this.foos = [1, 1].map(function() {
+ return new Foo();
+ });
+ }
+ var fooCollection = new FooCollection();
+ console.log(fooCollection.foos[0].isFoo(fooCollection.foos[0]));
+ console.log(fooCollection.foos[0].isFoo(fooCollection.foos[1]));
+ console.log(fooCollection.foos[1].isFoo(fooCollection.foos[0]));
+ console.log(fooCollection.foos[1].isFoo(fooCollection.foos[1]));
+ }
+ expect: {
+ function Foo() {
+ this.isFoo = function(o) {
+ return o instanceof Foo;
+ };
+ }
+ var fooCollection = new function() {
+ this.foos = [1, 1].map(function() {
+ return new Foo();
+ });
+ }();
+ console.log(fooCollection.foos[0].isFoo(fooCollection.foos[0]));
+ console.log(fooCollection.foos[0].isFoo(fooCollection.foos[1]));
+ console.log(fooCollection.foos[1].isFoo(fooCollection.foos[0]));
+ console.log(fooCollection.foos[1].isFoo(fooCollection.foos[1]));
+ }
+ expect_stdout: [
+ "true",
+ "true",
+ "true",
+ "true",
+ ]
+}