]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/controlFlowProfiler/switch-statements.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / controlFlowProfiler / switch-statements.js
1 load("./driver/driver.js");
2
3 var a, b, c;
4 function testSwitch(s) {
5 switch (s) {
6 case "foo":
7 return a;
8 case "bar":
9 return b;
10 default:
11 return c;
12 }
13 }
14
15 assert(!hasBasicBlockExecuted(testSwitch, "switch"), "should not have executed yet.");
16
17 testSwitch("foo");
18 assert(hasBasicBlockExecuted(testSwitch, "switch"), "should have executed.");
19 assert(hasBasicBlockExecuted(testSwitch, "return a"), "should have executed.");
20 assert(!hasBasicBlockExecuted(testSwitch, "return b"), "should not have executed yet.");
21 assert(!hasBasicBlockExecuted(testSwitch, "return c"), "should not have executed yet.");
22
23 testSwitch("bar");
24 assert(hasBasicBlockExecuted(testSwitch, "return b"), "should have executed.");
25 assert(!hasBasicBlockExecuted(testSwitch, "return c"), "should not have executed yet.");
26
27 testSwitch("");
28 assert(hasBasicBlockExecuted(testSwitch, "return c"), "should have executed.");