aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-05-20 15:58:46 +0800
committerGitHub <noreply@github.com>2017-05-20 15:58:46 +0800
commit58fae7dc070449e650d1a48ad7144cb5571a510f (patch)
treead1bce884d8ed589d4d3271155fe2cdd74c7ec97 /test
parent5bf8d7e9490155ed6fabea5f1140a87a1e9b596e (diff)
downloadtracifyjs-58fae7dc070449e650d1a48ad7144cb5571a510f.tar.gz
tracifyjs-58fae7dc070449e650d1a48ad7144cb5571a510f.zip
enhance `if_return` to handle `return void...` (#1977)
fixes #512
Diffstat (limited to 'test')
-rw-r--r--test/compress/if_return.js22
-rw-r--r--test/mocha/cli.js4
-rw-r--r--test/mocha/spidermonkey.js4
3 files changed, 28 insertions, 2 deletions
diff --git a/test/compress/if_return.js b/test/compress/if_return.js
index 0ac45c3c..c09d67b6 100644
--- a/test/compress/if_return.js
+++ b/test/compress/if_return.js
@@ -302,3 +302,25 @@ issue_1437_conditionals: {
}
}
}
+
+issue_512: {
+ options = {
+ conditionals: true,
+ if_return: true,
+ }
+ input: {
+ function a() {
+ if (b()) {
+ c();
+ return;
+ }
+ throw e;
+ }
+ }
+ expect: {
+ function a() {
+ if (!b()) throw e;
+ c();
+ }
+ }
+}
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 335b224d..db4a2c33 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -19,7 +19,9 @@ describe("bin/uglifyjs", function () {
eval(stdout);
assert.strictEqual(typeof WrappedUglifyJS, 'object');
- assert.strictEqual(WrappedUglifyJS.minify("foo([true,,2+3]);").code, "foo([!0,,5]);");
+ var result = WrappedUglifyJS.minify("foo([true,,2+3]);");
+ assert.strictEqual(result.error, undefined);
+ assert.strictEqual(result.code, "foo([!0,,5]);");
done();
});
diff --git a/test/mocha/spidermonkey.js b/test/mocha/spidermonkey.js
index a8a112d0..9bddb537 100644
--- a/test/mocha/spidermonkey.js
+++ b/test/mocha/spidermonkey.js
@@ -15,7 +15,9 @@ describe("spidermonkey export/import sanity test", function() {
eval(stdout);
assert.strictEqual(typeof SpiderUglify, "object");
- assert.strictEqual(SpiderUglify.minify("foo([true,,2+3]);").code, "foo([!0,,5]);");
+ var result = SpiderUglify.minify("foo([true,,2+3]);");
+ assert.strictEqual(result.error, undefined);
+ assert.strictEqual(result.code, "foo([!0,,5]);");
done();
});