support dumping AST (#1879)

Re-order `AST_Binary` properties to make dump more readable.

closes #769
This commit is contained in:
Alex Lam S.L
2017-05-08 06:23:01 +08:00
committed by GitHub
parent 4f8ca4626e
commit da295de82b
4 changed files with 45 additions and 6 deletions

View File

@@ -509,4 +509,15 @@ describe("bin/uglifyjs", function () {
return JSON.stringify(map).replace(/"/g, '\\"');
}
});
it("Should dump AST as JSON", function(done) {
var command = uglifyjscmd + " test/input/global_defs/simple.js -mco ast";
exec(command, function (err, stdout) {
if (err) throw err;
var ast = JSON.parse(stdout);
assert.strictEqual(ast._class, "AST_Toplevel");
assert.ok(Array.isArray(ast.body));
done();
});
});
});