aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-05 04:12:04 +0800
committerGitHub <noreply@github.com>2018-04-05 04:12:04 +0800
commitb5bab254ce2122a43e9ca0fdc757aecda7191576 (patch)
treed88a5122bbce4c7e2dfa5411b2dae4c47a531721 /test/mocha
parent81603ecd156f494a6b0c02655c5361152711300d (diff)
downloadtracifyjs-b5bab254ce2122a43e9ca0fdc757aecda7191576.tar.gz
tracifyjs-b5bab254ce2122a43e9ca0fdc757aecda7191576.zip
speed up `has_parens()` (take 2) (#3052)
fixes #3050
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/parentheses.js (renamed from test/mocha/new.js)23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/mocha/new.js b/test/mocha/parentheses.js
index 8f653f7a..a3ef8604 100644
--- a/test/mocha/new.js
+++ b/test/mocha/parentheses.js
@@ -1,7 +1,7 @@
var assert = require("assert");
var uglify = require("../../");
-describe("New", function() {
+describe("parentheses", function() {
it("Should add trailing parentheses for new expressions with zero arguments in beautify mode", function() {
var tests = [
"new x(1);",
@@ -83,4 +83,23 @@ describe("New", function() {
);
}
});
-}); \ No newline at end of file
+
+ it("Should compress leading parenthesis with reasonable performance", function() {
+ this.timeout(30000);
+ var code = [
+ "({}?0:1)&&x();",
+ "(function(){}).name;",
+ ];
+ for (var i = 16; --i >= 0;) {
+ [].push.apply(code, code);
+ }
+ code = code.join("");
+ var result = uglify.minify(code, {
+ compress: false,
+ mangle: false,
+ });
+ if (result.error) throw result.error;
+ // Dismal performance for `assert.strictEqual()` in Node.js 6
+ assert.ok(result.code === code);
+ });
+});