From 0f4cfa877a9f14a75b219c04947ce5984772d8ba Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 30 Oct 2019 03:49:39 +0800 Subject: fix corner case in `comments` (#3550) --- test/mocha/comments.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/mocha/comments.js b/test/mocha/comments.js index 764f6db8..9a4b3be6 100644 --- a/test/mocha/comments.js +++ b/test/mocha/comments.js @@ -259,6 +259,30 @@ describe("comments", function() { assert.strictEqual(result.code, code); }); + it("Should handle comments around parenthesis correctly", function() { + var code = [ + "a();", + "/* foo */", + "(b())", + "/* bar */", + "c();", + ].join("\n"); + var result = UglifyJS.minify(code, { + compress: false, + mangle: false, + output: { + comments: "all", + }, + }); + if (result.error) throw result.error; + assert.strictEqual(result.code, [ + "a();", + "/* foo */", + "b()", + "/* bar */;c();", + ].join("\n")); + }); + it("Should preserve comments around IIFE", function() { var result = UglifyJS.minify("/*a*/(/*b*/function(){/*c*/}/*d*/)/*e*/();", { compress: false, -- cgit v1.2.3