Fixes: #1156 #1161 Also add test to exercise Uglify after spidermonkey export/import of itself.
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
var assert = require("assert");
|
|
var exec = require("child_process").exec;
|
|
|
|
describe("spidermonkey export/import sanity test", function() {
|
|
it("should produce a functional build when using --self with spidermonkey", function (done) {
|
|
this.timeout(20000);
|
|
|
|
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
|
var command = uglifyjs + " --self -cm --wrap SpiderUglify --dump-spidermonkey-ast | " +
|
|
uglifyjs + " --spidermonkey -cm";
|
|
|
|
exec(command, function (err, stdout) {
|
|
if (err) throw err;
|
|
|
|
eval(stdout);
|
|
assert.strictEqual(typeof SpiderUglify, "object");
|
|
|
|
var ast = SpiderUglify.parse("foo([true,,2+3]);");
|
|
assert.strictEqual(true, ast instanceof SpiderUglify.AST_Node);
|
|
|
|
ast.figure_out_scope();
|
|
ast = SpiderUglify.Compressor({}).compress(ast);
|
|
assert.strictEqual(true, ast instanceof SpiderUglify.AST_Node);
|
|
|
|
var stream = SpiderUglify.OutputStream({});
|
|
ast.print(stream);
|
|
var code = stream.toString();
|
|
assert.strictEqual(code, "foo([!0,,5]);");
|
|
|
|
done();
|
|
});
|
|
});
|
|
});
|