aboutsummaryrefslogtreecommitdiff
path: root/test/compress/arrays.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/arrays.js')
-rw-r--r--test/compress/arrays.js43
1 files changed, 24 insertions, 19 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"
}