forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif-statement.js
58 lines (46 loc) · 1.9 KB
/
if-statement.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var hasBasicBlockExecuted = $vm.hasBasicBlockExecuted;
load("./driver/driver.js");
var a, b, c, d;
function testIf(x) {
if (x > 10 && x < 20) {
return a;
} else if (x > 20 && x < 30) {
return b;
} else if (x > 30 && x < 40) {
return c;
} else {
return d;
}
return null;
}
function noMatches(x) {
if (x > 10 && x < 20) {
return a;
} else if (x > 20 && x < 30) {
return b;
} else {
return c;
}
}
assert(!hasBasicBlockExecuted(testIf, "return a"), "should not have executed yet.");
assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
testIf(11);
assert(hasBasicBlockExecuted(testIf, "return a"), "should have executed.");
assert(hasBasicBlockExecuted(testIf, "x > 10"), "should have executed.");
assert(!hasBasicBlockExecuted(testIf, "return b"), "should not have executed yet.");
testIf(21);
assert(hasBasicBlockExecuted(testIf, "return b"), "should have executed.");
assert(!hasBasicBlockExecuted(testIf, "return c"), "should not have executed yet.");
testIf(31);
assert(hasBasicBlockExecuted(testIf, "return c"), "should have executed.");
assert(!hasBasicBlockExecuted(testIf, "return d"), "should not have executed yet.");
testIf(0);
assert(hasBasicBlockExecuted(testIf, "return d"), "should have executed.");
noMatches(0);
assert(!hasBasicBlockExecuted(noMatches, "return a"), "should not have executed yet.");
assert(hasBasicBlockExecuted(noMatches, "x > 10"), "should have executed.");
assert(!hasBasicBlockExecuted(noMatches, "return b"), "should not have executed yet.");
assert(hasBasicBlockExecuted(noMatches, "x > 20"), "should have executed.");
assert(hasBasicBlockExecuted(noMatches, "return c"), "should have executed.");