js/src/jit-test/tests/jaeger/testIfEqX.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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