js/src/jit-test/tests/basic/testincops.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial