diff options
author | kzc <zaxxon2011@gmail.com> | 2016-06-23 12:54:38 -0400 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2016-06-30 21:44:12 +0200 |
commit | 335b72df03fb6593d4bac8ddcde7d1b128eb3c4e (patch) | |
tree | aa1759d78036e14db6aec30ecbbd121a674611a0 /test/mocha/spidermonkey.js | |
parent | 3a7d53f3cfa81fc8df3cd61c9adf0ce6c28ecd30 (diff) | |
download | tracifyjs-335b72df03fb6593d4bac8ddcde7d1b128eb3c4e.tar.gz tracifyjs-335b72df03fb6593d4bac8ddcde7d1b128eb3c4e.zip |
Fix spidermonkey AST (ESTree) export and import, Array holes
Fixes: #1156 #1161
Also add test to exercise Uglify after spidermonkey export/import of itself.
Diffstat (limited to 'test/mocha/spidermonkey.js')
-rw-r--r-- | test/mocha/spidermonkey.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/mocha/spidermonkey.js b/test/mocha/spidermonkey.js new file mode 100644 index 00000000..f507ad1f --- /dev/null +++ b/test/mocha/spidermonkey.js @@ -0,0 +1,33 @@ +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(); + }); + }); +}); |