js/src/jit-test/tests/jaeger/testIfEqX.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 // Tests for IFEQX and GOTOX ops.
michael@0 2 function testIfElse() {
michael@0 3 var src =
michael@0 4 "var a = 0;\n" +
michael@0 5 "if (x) {\n";
michael@0 6 for (var i=0; i<7000; i++) {
michael@0 7 src += "a = 1;";
michael@0 8 }
michael@0 9 src += "} else {\n";
michael@0 10 for (var i=0; i<7000; i++) {
michael@0 11 src += "a = 2;";
michael@0 12 }
michael@0 13 src += "}\n";
michael@0 14 src += "return a;";
michael@0 15
michael@0 16 var f = new Function("x", src);
michael@0 17 assertEq(f(true), 1);
michael@0 18 assertEq(f(false), 2);
michael@0 19 assertEq(f([1, 2, 3]), 1);
michael@0 20 assertEq(f(), 2);
michael@0 21 }
michael@0 22 testIfElse();
michael@0 23
michael@0 24 function testWhile() {
michael@0 25 var src =
michael@0 26 "var i = 0, j = 0;\n" +
michael@0 27 "while (i++ < 50) {\n";
michael@0 28 for (var i=0; i<5000; i++) {
michael@0 29 src += "j = i;";
michael@0 30 }
michael@0 31 src += "}\n";
michael@0 32 src += "return j;";
michael@0 33
michael@0 34 var f = new Function(src);
michael@0 35 assertEq(f(), 50);
michael@0 36 }
michael@0 37 testWhile();

mercurial