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,17 +1,14 @@
var UglifyJS = require("../node");
var assert = require("assert");
var UglifyJS = require("../..");
describe("arguments", function() {
it("Should known that arguments in functions are local scoped", function() {
var ast = UglifyJS.parse("var arguments; var f = function() {arguments.length}");
ast.figure_out_scope();
// Test scope of `var arguments`
assert.strictEqual(ast.find_variable("arguments").global, true);
// Select arguments symbol in function
var symbol = ast.body[1].definitions[0].value.find_variable("arguments");
assert.strictEqual(symbol.global, false);
assert.strictEqual(symbol.scope, ast. // From ast
body[1]. // Select 2nd statement (equals to `var f ...`)
@@ -27,4 +24,4 @@ describe("arguments", function() {
assert.strictEqual(ast.body[0].body[0].uses_arguments, true);
assert.strictEqual(ast.body[0].body[0].body[0].uses_arguments, false);
});
});
});