Add scope test for arguments

This commit is contained in:
Anthony Van de Gejuchte
2016-01-14 22:32:46 +01:00
parent 6605d15783
commit 5c4e470d43

19
test/mocha/arguments.js Normal file
View File

@@ -0,0 +1,19 @@
var UglifyJS = require('../../');
var assert = require("assert");
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();
// Select 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 ...`)
definitions[0]. // First definition of selected statement
value // Select function as scope
);
});
});