aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/arrays.js43
-rw-r--r--test/compress/functions.js8
-rw-r--r--test/compress/reduce_vars.js29
3 files changed, 57 insertions, 23 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js
index f0ded06c..539dfb04 100644
--- a/test/compress/arrays.js
+++ b/test/compress/arrays.js
@@ -128,50 +128,55 @@ constant_join_3: {
for_loop: {
options = {
- unsafe : true,
- unused : true,
- evaluate : true,
- reduce_vars : true
+ evaluate: true,
+ reduce_vars: true,
+ unsafe: true,
};
input: {
function f0() {
var a = [1, 2, 3];
- for (var i = 0; i < a.length; i++) {
- console.log(a[i]);
- }
+ var b = 0;
+ for (var i = 0; i < a.length; i++)
+ b += a[i];
+ return b;
}
-
function f1() {
var a = [1, 2, 3];
- for (var i = 0, len = a.length; i < len; i++) {
- console.log(a[i]);
- }
+ var b = 0;
+ for (var i = 0, len = a.length; i < len; i++)
+ b += a[i];
+ return b;
}
-
function f2() {
var a = [1, 2, 3];
- for (var i = 0; i < a.length; i++) {
+ for (var i = 0; i < a.length; i++)
a[i]++;
- }
+ return a[2];
}
+ console.log(f0(), f1(), f2());
}
expect: {
function f0() {
var a = [1, 2, 3];
+ var b = 0;
for (var i = 0; i < 3; i++)
- console.log(a[i]);
+ b += a[i];
+ return b;
}
-
function f1() {
var a = [1, 2, 3];
- for (var i = 0; i < 3; i++)
- console.log(a[i]);
+ var b = 0;
+ for (var i = 0, len = a.length; i < len; i++)
+ b += a[i];
+ return b;
}
-
function f2() {
var a = [1, 2, 3];
for (var i = 0; i < a.length; i++)
a[i]++;
+ return a[2];
}
+ console.log(f0(), f1(), f2());
}
+ expect_stdout: "6 6 4"
}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index f411afa2..6c82557d 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -151,13 +151,13 @@ issue_1841_2: {
function_returning_constant_literal: {
options = {
+ inline: true,
+ passes: 2,
reduce_vars: true,
- unsafe: true,
+ side_effects: true,
toplevel: true,
- evaluate: true,
- cascade: true,
+ unsafe: true,
unused: true,
- inline: true,
}
input: {
function greeter() {
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index a03bc1c8..681dafd3 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2954,3 +2954,32 @@ const_expr_2: {
}
expect_stdout: "2 2"
}
+
+escaped_prop: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ inline: true,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unsafe: true,
+ unused: true,
+ }
+ input: {
+ var obj = { o: { a: 1 } };
+ (function(o) {
+ o.a++;
+ })(obj.o);
+ (function(o) {
+ console.log(o.a);
+ })(obj.o);
+ }
+ expect: {
+ var obj = { o: { a: 1 } };
+ obj.o.a++;
+ console.log(obj.o.a);
+ }
+ expect_stdout: "2"
+}