[Pkg-javascript-commits] [uglifyjs] 86/190: Add scope test for arguments

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:15 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit 5c4e470d43438e359fbdb93950e5d37d4df45a69
Author: Anthony Van de Gejuchte <anthonyvdgent at gmail.com>
Date:   Thu Jan 14 22:32:46 2016 +0100

    Add scope test for arguments
---
 test/mocha/arguments.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/test/mocha/arguments.js b/test/mocha/arguments.js
new file mode 100644
index 0000000..294a6c1
--- /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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list