diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-19 00:36:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 00:36:30 +0800 |
commit | 082e004b872ecb158e5a28702898688742b5da86 (patch) | |
tree | 81b5183f9f108c64680d106c0d51af43c4751e5a /test/compress | |
parent | 983e69128b0e6da78d71ad9b77d798f31a10ca44 (diff) | |
download | tracifyjs-082e004b872ecb158e5a28702898688742b5da86.tar.gz tracifyjs-082e004b872ecb158e5a28702898688742b5da86.zip |
compress `undefined` property names (#2811)
- enforce property names as string
- handle `void 0` as `undefined` in `hoist_props` & `reduce_vars`
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/hoist_props.js | 22 | ||||
-rw-r--r-- | test/compress/issue-1770.js | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index 012a3fca..03867f78 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -664,3 +664,25 @@ issue_2519: { } expect_stdout: "5.5" } + +undefined_key: { + options = { + evaluate: true, + hoist_props: true, + join_vars: true, + passes: 4, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a, o = {}; + o[a] = 1; + o.b = 2; + console.log(o[a] + o.b); + } + expect: { + console.log(3); + } + expect_stdout: "3" +} diff --git a/test/compress/issue-1770.js b/test/compress/issue-1770.js index f63f8453..7a529b2c 100644 --- a/test/compress/issue-1770.js +++ b/test/compress/issue-1770.js @@ -84,12 +84,12 @@ numeric_literal: { ' 0: 0,', ' "-0": 1,', ' 42: 2,', - ' "42": 3,', + ' 42: 3,', ' 37: 4,', ' o: 5,', ' 1e42: 6,', ' b: 7,', - ' "1e+42": 8', + ' 1e42: 8', '};', '', 'console.log(obj[-0], obj[-""], obj["-0"]);', |