Files
kotlin-fork/js/js.translator/testData/js-optimizer/while-condition-folding/whileEvaluationOrder.optimized.js
T
Alexey Andreev 05dd039151 KT-12275 Add JS optimization that transforms the following code
```
do {
    X
    if (B) break;
} while (A)
```

to

```
do {
    X
} while (!B && A)
```

Add inversion that takes boolean expression and applies negation to it, simplifying if possible (like !!a => a).
2016-07-25 18:46:46 +03:00

20 lines
358 B
JavaScript
Vendored

var global = "";
function foo(x) {
global += x + ";";
return x;
}
function box() {
var i = 1;
var sum = 0;
while (foo(i) < 10 && foo(sum) <= 30) {
sum += i;
i++;
}
if (global != "1;0;2;1;3;3;4;6;5;10;6;15;7;21;8;28;9;36;") return "fail1: " + global;
if (sum != 36) return "fail2: " + sum;
return "OK"
}