blob: 85e36abe36ba6e530660f4a6c00d0cd5375ace75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var globalinc = 0;
function testincops(n) {
var i = 0, o = {p:0}, a = [0];
n = 100;
for (i = 0; i < n; i++);
while (i-- > 0);
for (i = 0; i < n; ++i);
while (--i >= 0);
for (o.p = 0; o.p < n; o.p++) globalinc++;
while (o.p-- > 0) --globalinc;
for (o.p = 0; o.p < n; ++o.p) ++globalinc;
while (--o.p >= 0) globalinc--;
++i; // set to 0
for (a[i] = 0; a[i] < n; a[i]++);
while (a[i]-- > 0);
for (a[i] = 0; a[i] < n; ++a[i]);
while (--a[i] >= 0);
return [++o.p, ++a[i], globalinc].toString();
}
assertEq(testincops(), "0,0,0");
|