diff options
author | kzc <kzc@users.noreply.github.com> | 2017-05-01 12:10:11 -0400 |
---|---|---|
committer | Alex Lam S.L <alexlamsl@gmail.com> | 2017-05-02 00:10:11 +0800 |
commit | ea9289771b79c273347af72fba024ca29cfa035d (patch) | |
tree | 8bfe0c9e13be06c03eaaf438298eba4abee1c1a8 /test | |
parent | 2cb55b2ad0119852bc8714401992724d4fdb224d (diff) | |
download | tracifyjs-ea9289771b79c273347af72fba024ca29cfa035d.tar.gz tracifyjs-ea9289771b79c273347af72fba024ca29cfa035d.zip |
improve literal return optimization (#1860)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/functions.js | 22 | ||||
-rw-r--r-- | test/compress/issue-1787.js | 6 | ||||
-rw-r--r-- | test/compress/negate-iife.js | 8 |
3 files changed, 25 insertions, 11 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index 2a2d0965..3a560f00 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -145,3 +145,25 @@ issue_1841_2: { } expect_exact: "42" } + +function_returning_constant_literal: { + options = { + reduce_vars: true, + unsafe: true, + toplevel: true, + evaluate: true, + cascade: true, + unused: true, + } + input: { + function greeter() { + return { message: 'Hello there' }; + } + var greeting = greeter(); + console.log(greeting.message); + } + expect: { + console.log("Hello there"); + } + expect_stdout: "Hello there" +} diff --git a/test/compress/issue-1787.js b/test/compress/issue-1787.js index 43d1f1be..02fa0f91 100644 --- a/test/compress/issue-1787.js +++ b/test/compress/issue-1787.js @@ -10,10 +10,6 @@ unary_prefix: { return x; }()); } - expect: { - console.log(function() { - return -2 / 3; - }()); - } + expect_exact: "console.log(-2/3);" expect_stdout: true } diff --git a/test/compress/negate-iife.js b/test/compress/negate-iife.js index 343e8e16..514a15c7 100644 --- a/test/compress/negate-iife.js +++ b/test/compress/negate-iife.js @@ -25,11 +25,9 @@ negate_iife_2: { negate_iife: true }; input: { - (function(){ return {} })().x = 10; // should not transform this one - } - expect: { (function(){ return {} })().x = 10; } + expect_exact: "({}).x=10;" } negate_iife_2_side_effects: { @@ -38,11 +36,9 @@ negate_iife_2_side_effects: { side_effects: true, } input: { - (function(){ return {} })().x = 10; // should not transform this one - } - expect: { (function(){ return {} })().x = 10; } + expect_exact: "({}).x=10;" } negate_iife_3: { |