diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-01-26 19:14:18 +0800 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2017-01-26 12:14:18 +0100 |
commit | 0d7d4918eb6fb73c3cf9863479b3e66d38fad6df (patch) | |
tree | aba146adb5371e19935493b132fc605abbe081ca /test/compress/properties.js | |
parent | 48284844a461e6113bb9911cdcdad7ab8a3d85de (diff) | |
download | tracifyjs-0d7d4918eb6fb73c3cf9863479b3e66d38fad6df.tar.gz tracifyjs-0d7d4918eb6fb73c3cf9863479b3e66d38fad6df.zip |
augment evaluate to extract within objects (#1425)
- gated by `unsafe`
- replaces previous optimisation specific to String.length
- "123"[0] => 1
- [1, 2, 3][0] => 1
- [1, 2, 3].length => 3
- does not apply to objects with overridden prototype functions
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r-- | test/compress/properties.js | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js index 22f2c339..7ad54ebe 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -54,7 +54,56 @@ dot_properties_es5: { } } -evaluate_length: { +sub_properties: { + options = { + evaluate: true, + properties: true + }; + input: { + a[0] = 0; + a["0"] = 1; + a[3.14] = 2; + a["3" + ".14"] = 3; + a["i" + "f"] = 4; + a["foo" + " bar"] = 5; + a[0 / 0] = 6; + a[null] = 7; + a[undefined] = 8; + } + expect: { + a[0] = 0; + a[0] = 1; + a[3.14] = 2; + a[3.14] = 3; + a.if = 4; + a["foo bar"] = 5; + a[NaN] = 6; + a[null] = 7; + a[void 0] = 8; + } +} + +evaluate_array_length: { + options = { + properties: true, + unsafe: true, + evaluate: true + }; + input: { + a = [1, 2, 3].length; + a = [1, 2, 3].join()["len" + "gth"]; + a = [1, 2, b].length; + a = [1, 2, 3].join(b).length; + } + expect: { + a = 3; + a = 5; + a = [1, 2, b].length; + a = [1, 2, 3].join(b).length; + } +} + +evaluate_string_length: { options = { properties: true, unsafe: true, |