Debian Codegraph @

test/instrument/control/if.t

raw
1 Instrumentation of branches.
2
3 $ bash ../test.sh <<'EOF'
4 > let _ = if true then 1 else 2
5 > EOF
6 let _ =
7 if true then (
8 ___bisect_visit___ 1;
9 1)
10 else (
11 ___bisect_visit___ 0;
12 2)
13
14
15 Recursive instrumentation of subexpressions.
16
17 $ bash ../test.sh <<'EOF'
18 > let _ =
19 > if if true then true else false then
20 > if true then true else false
21 > else
22 > if true then true else false
23 > EOF
24 let _ =
25 if
26 if true then (
27 ___bisect_visit___ 1;
28 true)
29 else (
30 ___bisect_visit___ 0;
31 false)
32 then (
33 ___bisect_visit___ 7;
34 if true then (
35 ___bisect_visit___ 3;
36 true)
37 else (
38 ___bisect_visit___ 2;
39 false))
40 else (
41 ___bisect_visit___ 6;
42 if true then (
43 ___bisect_visit___ 5;
44 true)
45 else (
46 ___bisect_visit___ 4;
47 false))
48
49
50 Supports if-then.
51
52 $ bash ../test.sh <<'EOF'
53 > let _ = if true then ()
54 > EOF
55 let _ =
56 if true then (
57 ___bisect_visit___ 0;
58 ())
59
60
61 The next expression after if-then is instrumented as if it were an else-case.
62
63 $ bash ../test.sh <<'EOF'
64 > let _ = (if true then ()); ()
65 > EOF
66 let _ =
67 if true then (
68 ___bisect_visit___ 1;
69 ());
70 ___bisect_visit___ 0;
71 ()
72
73
74 Condition does not need its out-edge instrumented. Expressions in cases are in
75 tail position iff the whole if-expression is in tail position.
76
77 $ bash ../test.sh <<'EOF'
78 > let _ =
79 > if bool_of_string "true" then print_endline "foo" else print_endline "bar"
80 > let _ = fun () ->
81 > if bool_of_string "true" then print_endline "foo" else print_endline "bar"
82 > EOF
83 let _ =
84 if bool_of_string "true" then (
85 ___bisect_visit___ 3;
86 ___bisect_post_visit___ 0 (print_endline "foo"))
87 else (
88 ___bisect_visit___ 2;
89 ___bisect_post_visit___ 1 (print_endline "bar"))
90
91 let _ =
92 fun () ->
93 ___bisect_visit___ 6;
94 if bool_of_string "true" then (
95 ___bisect_visit___ 5;
96 print_endline "foo")
97 else (
98 ___bisect_visit___ 4;
99 print_endline "bar")