aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/spidermonkey.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocha/spidermonkey.js')
-rw-r--r--test/mocha/spidermonkey.js33
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();
+ });
+ });
+});