aboutsummaryrefslogtreecommitdiff
path: root/test/compress/properties.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-10-29 04:11:26 +0800
committerGitHub <noreply@github.com>2017-10-29 04:11:26 +0800
commit8428326ea120dece51b70d7bba63dda8eda14fd6 (patch)
tree8c634bb30a6845048dee5cc27590a4a654d7ac24 /test/compress/properties.js
parent31f82091930b39ebb5d9358951c39ae20cf8057e (diff)
downloadtracifyjs-8428326ea120dece51b70d7bba63dda8eda14fd6.tar.gz
tracifyjs-8428326ea120dece51b70d7bba63dda8eda14fd6.zip
enhance `properties` (#2412)
- trim array items only if `side_effects` - extend to non-identifier properties
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r--test/compress/properties.js51
1 files changed, 35 insertions, 16 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js
index f435d371..1b5e7fc7 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -1,7 +1,8 @@
keep_properties: {
options = {
- properties: false
- };
+ evaluate: true,
+ properties: false,
+ }
input: {
a["foo"] = "bar";
}
@@ -12,6 +13,7 @@ keep_properties: {
dot_properties: {
options = {
+ evaluate: true,
properties: true,
}
beautify = {
@@ -37,6 +39,7 @@ dot_properties: {
dot_properties_es5: {
options = {
+ evaluate: true,
properties: true,
}
beautify = {
@@ -61,8 +64,8 @@ dot_properties_es5: {
sub_properties: {
options = {
evaluate: true,
- properties: true
- };
+ properties: true,
+ }
input: {
a[0] = 0;
a["0"] = 1;
@@ -81,18 +84,18 @@ sub_properties: {
a[3.14] = 3;
a.if = 4;
a["foo bar"] = 5;
- a[NaN] = 6;
- a[null] = 7;
+ a.NaN = 6;
+ a.null = 7;
a[void 0] = 8;
}
}
evaluate_array_length: {
options = {
+ evaluate: true,
properties: true,
unsafe: true,
- evaluate: true
- };
+ }
input: {
a = [1, 2, 3].length;
a = [1, 2, 3].join()["len" + "gth"];
@@ -109,10 +112,10 @@ evaluate_array_length: {
evaluate_string_length: {
options = {
+ evaluate: true,
properties: true,
unsafe: true,
- evaluate: true
- };
+ }
input: {
a = "foo".length;
a = ("foo" + "bar")["len" + "gth"];
@@ -151,7 +154,8 @@ mangle_properties: {
mangle_unquoted_properties: {
options = {
- properties: false
+ evaluate: true,
+ properties: false,
}
mangle = {
properties: {
@@ -249,7 +253,8 @@ mangle_debug_suffix: {
mangle_debug_suffix_keep_quoted: {
options = {
- properties: false
+ evaluate: true,
+ properties: false,
}
mangle = {
properties: {
@@ -833,18 +838,29 @@ lhs_prop_2: {
unused: true,
}
input: {
+ [1][0] = 42;
(function(a) {
- a[2] = "g";
+ a.b = "g";
})("abc");
+ (function(a) {
+ a[2] = "g";
+ })("def");
+ (function(a) {
+ a[""] = "g";
+ })("ghi");
}
expect: {
- "abc"[2] = "g";
+ [1][0] = 42;
+ "abc".b = "g";
+ "def"[2] = "g";
+ "ghi"[""] = "g";
}
}
literal_duplicate_key_side_effects: {
options = {
properties: true,
+ side_effects: true,
}
input: {
console.log({
@@ -864,6 +880,7 @@ prop_side_effects_1: {
inline: true,
properties: true,
reduce_vars: true,
+ side_effects: true,
toplevel: true,
unused: true,
}
@@ -899,6 +916,7 @@ prop_side_effects_2: {
passes: 2,
properties: true,
reduce_vars: true,
+ side_effects: true,
toplevel: true,
unused: true,
}
@@ -906,11 +924,11 @@ prop_side_effects_2: {
var C = 1;
console.log(C);
var obj = {
- bar: function() {
+ "": function() {
return C + C;
}
};
- console.log(obj.bar());
+ console.log(obj[""]());
}
expect: {
console.log(1);
@@ -974,6 +992,7 @@ accessor_2: {
array_hole: {
options = {
properties: true,
+ side_effects: true,
}
input: {
console.log(