retain comments within brackets (#2999)

fixes #2998
This commit is contained in:
Alex Lam S.L
2018-03-13 18:44:21 +08:00
committed by GitHub
parent 5429234138
commit 188c39e8d5
2 changed files with 30 additions and 9 deletions

View File

@@ -139,6 +139,26 @@ describe("Comment", function() {
assert.strictEqual(result.code, code);
});
it("Should retain comments within brackets", function() {
var code = [
"{/* foo */}",
"a({/* foo */});",
"while (a) {/* foo */}",
"switch (a) {/* foo */}",
"if (a) {/* foo */} else {/* bar */}",
].join("\n\n");
var result = uglify.minify(code, {
compress: false,
mangle: false,
output: {
beautify: true,
comments: "all",
},
});
if (result.error) throw result.error;
assert.strictEqual(result.code, code);
});
it("Should correctly preserve new lines around comments", function() {
var tests = [
[