aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-19 00:36:30 +0800
committerGitHub <noreply@github.com>2018-01-19 00:36:30 +0800
commit082e004b872ecb158e5a28702898688742b5da86 (patch)
tree81b5183f9f108c64680d106c0d51af43c4751e5a /test
parent983e69128b0e6da78d71ad9b77d798f31a10ca44 (diff)
downloadtracifyjs-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')
-rw-r--r--test/compress/hoist_props.js22
-rw-r--r--test/compress/issue-1770.js4
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"]);',