improve mocha tests (#3195)

This commit is contained in:
Alex Lam S.L
2018-06-22 01:04:15 +08:00
committed by alexlamsl
parent 766a4147d4
commit 28330913d8
22 changed files with 562 additions and 581 deletions

View File

@@ -1,20 +1,20 @@
var assert = require("assert");
var uglify = require("../node");
var UglifyJS = 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);
UglifyJS.parse(code);
}
var error = function(e) {
return e instanceof uglify.JS_Parse_Error &&
e.message === "Strict mode may not include a with statement";
return e instanceof UglifyJS.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)}");
var ast = UglifyJS.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);