aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2017-02-21 14:24:18 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-21 14:24:18 +0800
commit1e51586996ae4fdac68a8ea597c20ab170809c43 (patch)
treee276bab43989f7bddb3cee6e147130bf410c675f /test/mocha
parentd48a3080ac873ae531a2d87679a26c5941814843 (diff)
downloadtracifyjs-1e51586996ae4fdac68a8ea597c20ab170809c43.tar.gz
tracifyjs-1e51586996ae4fdac68a8ea597c20ab170809c43.zip
Support marking a call as pure
A function call or IIFE with an immediately preceding comment containing `@__PURE__` or `#__PURE__` is deemed to be a side-effect-free pure function call and can potentially be dropped. Depends on `side_effects` option. `[#@]__PURE__` hint will be removed from comment when pure call is dropped. fixes #1261 closes #1448
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/minify.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/mocha/minify.js b/test/mocha/minify.js
index 70cf73ae..8fe1565f 100644
--- a/test/mocha/minify.js
+++ b/test/mocha/minify.js
@@ -95,4 +95,19 @@ describe("minify", function() {
assert.strictEqual(code, "var a=function(n){return n};");
});
});
+
+ describe("#__PURE__", function() {
+ it("should drop #__PURE__ hint after use", function() {
+ var result = Uglify.minify('//@__PURE__ comment1 #__PURE__ comment2\n foo(), bar();', {
+ fromString: true,
+ output: {
+ comments: "all",
+ beautify: false,
+ }
+ });
+ var code = result.code;
+ assert.strictEqual(code, "// comment1 comment2\nbar();");
+ });
+ });
+
});