]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/controlFlowProfiler/if-statement.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / controlFlowProfiler / if-statement.js
CommitLineData
ed1e77d3
A
1load("./driver/driver.js");
2
3var a, b, c, d;
4
5function 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
19function 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
29assert(!hasBasicBlockExecuted(testIf, "return a"), "should not have executed yet.");
30assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
31assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
32assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
33
34testIf(11);
35assert(hasBasicBlockExecuted(testIf, "return a"), "should have executed.");
36assert(hasBasicBlockExecuted(testIf, "x > 10"), "should have executed.");
37assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
38
39testIf(21);
40assert(hasBasicBlockExecuted(testIf, "return b"), "should have executed.");
41assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
42
43testIf(31);
44assert(hasBasicBlockExecuted(testIf, "return c"), "should have executed.");
45assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
46
47testIf(0);
48assert(hasBasicBlockExecuted(testIf, "return d"), "should have executed.");
49
50
51noMatches(0);
52assert(!hasBasicBlockExecuted(noMatches, "return a"), "should not have executed yet.");
53assert(hasBasicBlockExecuted(noMatches, "x > 10"), "should have executed.");
54assert(!hasBasicBlockExecuted(noMatches, "return b"), "should not have executed yet.");
55assert(hasBasicBlockExecuted(noMatches, "x > 20"), "should have executed.");
56assert(hasBasicBlockExecuted(noMatches, "return c"), "should have executed.");