From 58fae7dc070449e650d1a48ad7144cb5571a510f Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 20 May 2017 15:58:46 +0800 Subject: enhance `if_return` to handle `return void...` (#1977) fixes #512 --- test/compress/if_return.js | 22 ++++++++++++++++++++++ test/mocha/cli.js | 4 +++- test/mocha/spidermonkey.js | 4 +++- 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'test') 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(); }); -- cgit v1.2.3