blob: 72fd76ef879cad2f4a1844bb26b7f6cbd4ad970c (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
var assert = require("assert");
var uglify = require("../node");
describe("With", 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);
}
var error = function(e) {
return e instanceof uglify.JS_Parse_Error &&
e.message === "Strict mode may not include a with statement";
}
assert.throws(test, error);
});
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);
});
});
|