more tests for #2938 (#2940)
authorAlex Lam S.L <alexlamsl@gmail.com>
Tue, 20 Feb 2018 20:19:42 +0000 (04:19 +0800)
committerGitHub <noreply@github.com>
Tue, 20 Feb 2018 20:19:42 +0000 (04:19 +0800)
test/compress/pure_getters.js

index 82229d4..e266286 100644 (file)
@@ -772,3 +772,61 @@ issue_2938_2: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2938_3: {
+    options = {
+        pure_getters: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        function f(a) {
+            var unused = a.a;
+            a.b = "PASS";
+            a.c;
+        }
+        var o = {};
+        o.d;
+        f(o);
+        console.log(o.b);
+    }
+    expect: {
+        function f(a) {
+            a.b = "PASS";
+        }
+        var o = {};
+        f(o);
+        console.log(o.b);
+    }
+    expect_stdout: "PASS"
+}
+
+issue_2938_4: {
+    options = {
+        pure_getters: true,
+        side_effects: true,
+        toplevel: true,
+        unused: true,
+    }
+    input: {
+        var Parser = function Parser() {};
+        var p = Parser.prototype;
+        var unused = p.x;
+        p.initialContext = function initialContext() {
+            p.y;
+            console.log("PASS");
+        };
+        p.braceIsBlock = function() {};
+        (new Parser).initialContext();
+    }
+    expect: {
+        var Parser = function() {};
+        var p = Parser.prototype;
+        p.initialContext = function() {
+            console.log("PASS");
+        };
+        p.braceIsBlock = function() {};
+        (new Parser).initialContext();
+    }
+    expect_stdout: "PASS"
+}