Merge branch 'master' into harmony
This commit is contained in:
@@ -186,7 +186,7 @@ describe("Directives", function() {
|
||||
});
|
||||
|
||||
it("Should test EXPECT_DIRECTIVE RegExp", function() {
|
||||
var tests = [
|
||||
[
|
||||
["", true],
|
||||
["'test';", true],
|
||||
["'test';;", true],
|
||||
@@ -195,11 +195,12 @@ describe("Directives", function() {
|
||||
["'tests'; \n\t", true],
|
||||
["'tests';\n\n", true],
|
||||
["\n\n\"use strict\";\n\n", true]
|
||||
];
|
||||
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
assert.strictEqual(uglify.EXPECT_DIRECTIVE.test(tests[i][0]), tests[i][1], tests[i][0]);
|
||||
}
|
||||
].forEach(function(test) {
|
||||
var out = uglify.OutputStream();
|
||||
out.print(test[0]);
|
||||
out.print_string("", null, true);
|
||||
assert.strictEqual(out.get() === test[0] + ';""', test[1], test[0]);
|
||||
});
|
||||
});
|
||||
|
||||
it("Should only print 2 semicolons spread over 2 lines in beautify mode", function() {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
var uglify = require('../../');
|
||||
var assert = require("assert");
|
||||
|
||||
describe("For statement", function() {
|
||||
it("For variable should list enclosing scope in its references (issue #17022)", function() {
|
||||
var ast = uglify.parse("function f() { for (var a = 0; a < 10; a++) {} }");
|
||||
ast.figure_out_scope();
|
||||
|
||||
var checkWalker = new uglify.TreeWalker(function(node, descend) {
|
||||
if (node instanceof uglify.AST_VarDef) {
|
||||
console.log("AST_VarDef");
|
||||
// one reference should be in the AST_Defun scope - search for it
|
||||
|
||||
var walkNode = function (r) {
|
||||
console.log(r.CTOR.name);
|
||||
var walker = new uglify.TreeWalker(function(node, descend){
|
||||
// do not walk into any other scope, it should be listed if needed
|
||||
console.log(" " + node.CTOR.name);
|
||||
if (node instanceof uglify.AST_Scope && node != r.scope) return true;
|
||||
if (node instanceof uglify.AST_For) {
|
||||
console.log("Great - we found the for statement referencing the variable")
|
||||
}
|
||||
return false;
|
||||
});
|
||||
r.scope.walk(walker);
|
||||
r.walk(walker);
|
||||
};
|
||||
|
||||
node.name.thedef.orig.forEach(walkNode);
|
||||
node.name.thedef.references.forEach(walkNode);
|
||||
}
|
||||
});
|
||||
ast.walk(checkWalker);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user