aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2016-01-14 22:32:46 +0100
committerAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2016-01-14 22:32:46 +0100
commit5c4e470d43438e359fbdb93950e5d37d4df45a69 (patch)
treef87748842b942482b4d15cdaff8fbf462dd84f13
parent6605d1578351939ee0e39a13bf68cc9c1708c918 (diff)
downloadtracifyjs-5c4e470d43438e359fbdb93950e5d37d4df45a69.tar.gz
tracifyjs-5c4e470d43438e359fbdb93950e5d37d4df45a69.zip
Add scope test for arguments
-rw-r--r--test/mocha/arguments.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/mocha/arguments.js b/test/mocha/arguments.js
new file mode 100644
index 00000000..294a6c16
--- /dev/null
+++ b/test/mocha/arguments.js
@@ -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
+ );
+ });
+}); \ No newline at end of file