var ex = expression(true);
var len = start.comments_before.length;
[].unshift.apply(ex.start.comments_before, start.comments_before);
+ start.comments_before.length = 0;
start.comments_before = ex.start.comments_before;
start.comments_before_length = len;
if (len == 0 && start.comments_before.length > 0) {
var end = prev();
end.comments_before = ex.end.comments_before;
[].push.apply(ex.end.comments_after, end.comments_after);
+ end.comments_after.length = 0;
end.comments_after = ex.end.comments_after;
ex.end = end;
if (ex instanceof AST_Call) mark_pure(ex);
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,