]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/controlFlowProfiler/if-statement.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / controlFlowProfiler / if-statement.js
1 load("./driver/driver.js");
2
3 var a, b, c, d;
4
5 function testIf(x) {
6 if (x > 10 && x < 20) {
7 return a;
8 } else if (x > 20 && x < 30) {
9 return b;
10 } else if (x > 30 && x < 40) {
11 return c;
12 } else {
13 return d;
14 }
15
16 return null;
17 }
18
19 function noMatches(x) {
20 if (x > 10 && x < 20) {
21 return a;
22 } else if (x > 20 && x < 30) {
23 return b;
24 } else {
25 return c;
26 }
27 }
28
29 assert(!hasBasicBlockExecuted(testIf, "return a"), "should not have executed yet.");
30 assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
31 assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
32 assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
33
34 testIf(11);
35 assert(hasBasicBlockExecuted(testIf, "return a"), "should have executed.");
36 assert(hasBasicBlockExecuted(testIf, "x > 10"), "should have executed.");
37 assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
38
39 testIf(21);
40 assert(hasBasicBlockExecuted(testIf, "return b"), "should have executed.");
41 assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
42
43 testIf(31);
44 assert(hasBasicBlockExecuted(testIf, "return c"), "should have executed.");
45 assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
46
47 testIf(0);
48 assert(hasBasicBlockExecuted(testIf, "return d"), "should have executed.");
49
50
51 noMatches(0);
52 assert(!hasBasicBlockExecuted(noMatches, "return a"), "should not have executed yet.");
53 assert(hasBasicBlockExecuted(noMatches, "x > 10"), "should have executed.");
54 assert(!hasBasicBlockExecuted(noMatches, "return b"), "should not have executed yet.");
55 assert(hasBasicBlockExecuted(noMatches, "x > 20"), "should have executed.");
56 assert(hasBasicBlockExecuted(noMatches, "return c"), "should have executed.");