]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/controlFlowProfiler/conditional-expression.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / controlFlowProfiler / conditional-expression.js
1 load("./driver/driver.js");
2
3 function foo(){ }
4 function bar(){ }
5 function baz(){ }
6
7 function testConditionalBasic(x) {
8 return x ? 10 : 20;
9 }
10
11
12 testConditionalBasic(false);
13 checkBasicBlock(testConditionalBasic, "x", ShouldHaveExecuted);
14 checkBasicBlock(testConditionalBasic, "20", ShouldHaveExecuted);
15 checkBasicBlock(testConditionalBasic, "10", ShouldNotHaveExecuted);
16
17 testConditionalBasic(true);
18 checkBasicBlock(testConditionalBasic, "10", ShouldHaveExecuted);
19
20
21 function testConditionalFunctionCall(x, y) {
22 x ? y ? foo()
23 : baz()
24 : bar()
25 }
26 testConditionalFunctionCall(false, false);
27 checkBasicBlock(testConditionalFunctionCall, "x", ShouldHaveExecuted);
28 checkBasicBlock(testConditionalFunctionCall, "? y", ShouldHaveExecuted);
29 checkBasicBlock(testConditionalFunctionCall, "bar", ShouldHaveExecuted);
30 checkBasicBlock(testConditionalFunctionCall, ": bar", ShouldHaveExecuted);
31 checkBasicBlock(testConditionalFunctionCall, "y", ShouldNotHaveExecuted);
32 checkBasicBlock(testConditionalFunctionCall, "? foo", ShouldNotHaveExecuted);
33 checkBasicBlock(testConditionalFunctionCall, "foo", ShouldNotHaveExecuted);
34 checkBasicBlock(testConditionalFunctionCall, "baz", ShouldNotHaveExecuted);
35
36 testConditionalFunctionCall(true, false);
37 checkBasicBlock(testConditionalFunctionCall, "y", ShouldHaveExecuted);
38 checkBasicBlock(testConditionalFunctionCall, "? foo", ShouldHaveExecuted);
39 checkBasicBlock(testConditionalFunctionCall, ": baz", ShouldHaveExecuted);
40 checkBasicBlock(testConditionalFunctionCall, "baz", ShouldHaveExecuted);
41 checkBasicBlock(testConditionalFunctionCall, "foo", ShouldNotHaveExecuted);
42
43 testConditionalFunctionCall(true, true);
44 checkBasicBlock(testConditionalFunctionCall, "foo", ShouldHaveExecuted);