PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/zpao/v8monkey
JavaScript | 37 lines | 33 code | 3 blank | 1 comment | 3 complexity | 2cf9c899528997a179497cefa0c46734 MD5 | raw file
 1// Tests for IFEQX and GOTOX ops.
 2function testIfElse() {
 3    var src =
 4        "var a = 0;\n" +
 5        "if (x) {\n";
 6    for (var i=0; i<7000; i++) {
 7        src += "a = 1;";
 8    }
 9    src += "} else {\n";
10    for (var i=0; i<7000; i++) {
11        src += "a = 2;";
12    }
13    src += "}\n";
14    src += "return a;";
15
16    var f = new Function("x", src);
17    assertEq(f(true), 1);
18    assertEq(f(false), 2);
19    assertEq(f([1, 2, 3]), 1);
20    assertEq(f(), 2);
21}
22testIfElse();
23
24function testWhile() {
25    var src =
26        "var i = 0, j = 0;\n" +
27        "while (i++ < 50) {\n";
28    for (var i=0; i<5000; i++) {
29        src += "j = i;";
30    }
31    src += "}\n";
32    src += "return j;";
33
34    var f = new Function(src);
35    assertEq(f(), 50);
36}
37testWhile();