Backport mocha with test from harmony
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>
Sun, 3 Jul 2016 22:51:09 +0000 (00:51 +0200)
committerAnthony Van de Gejuchte <anthonyvdgent@gmail.com>
Sun, 3 Jul 2016 22:51:09 +0000 (00:51 +0200)
test/mocha/with.js

index 2e758d1..734e1e1 100644 (file)
@@ -2,7 +2,7 @@ var assert = require("assert");
 var uglify = require("../../");
 
 describe("With", function() {
-    it ("Should throw syntaxError when using with statement in strict mode", function() {
+    it("Should throw syntaxError when using with statement in strict mode", function() {
         var code = '"use strict";\nthrow NotEarlyError;\nwith ({}) { }';
         var test = function() {
             uglify.parse(code);
@@ -13,4 +13,11 @@ describe("With", function() {
         }
         assert.throws(test, error);
     });
-});
\ No newline at end of file
+    it("Should set uses_with for scopes involving With statements", function() {
+        var ast = uglify.parse("with(e) {f(1, 2)}");
+        ast.figure_out_scope();
+        assert.equal(ast.uses_with, true);
+        assert.equal(ast.body[0].expression.scope.uses_with, true);
+        assert.equal(ast.body[0].body.body[0].body.expression.scope.uses_with, true);
+    });
+});