aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-05-02 13:50:51 +0800
committerGitHub <noreply@github.com>2019-05-02 13:50:51 +0800
commita89d424a0bd85c80a6b49b6585143ff723a243ca (patch)
treed7fb8e2d4e13bc78262170dc9cd346eee5afa4e7 /test/mocha
parent429d2b56b770f18cef72c2590eabecc6300b9922 (diff)
downloadtracifyjs-a89d424a0bd85c80a6b49b6585143ff723a243ca.tar.gz
tracifyjs-a89d424a0bd85c80a6b49b6585143ff723a243ca.zip
render comments in custom ASTs gracefully (#3393)
fixes #3246
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/comments.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/mocha/comments.js b/test/mocha/comments.js
index 1ca1432a..3907f2fa 100644
--- a/test/mocha/comments.js
+++ b/test/mocha/comments.js
@@ -260,6 +260,23 @@ describe("comments", function() {
].join("\n"));
});
+ it("Should handle programmatic AST insertions gracefully", function() {
+ var ast = UglifyJS.parse([
+ "function f() {",
+ " //foo",
+ " bar;",
+ " return;",
+ "}",
+ ].join("\n"));
+ ast.body[0].body[0] = new UglifyJS.AST_Throw({value: ast.body[0].body[0].body});
+ ast.body[0].body[1].value = new UglifyJS.AST_Number({value: 42});
+ assert.strictEqual(ast.print_to_string({comments: "all"}), [
+ "function f(){",
+ "//foo",
+ "throw bar;return 42}",
+ ].join("\n"));
+ });
+
describe("comment before constant", function() {
var js = 'function f() { /*c1*/ var /*c2*/ foo = /*c3*/ false; return foo; }';