| 1 |
Logical OR is expanded so that the operands can be instrumented individually. |
| 2 |
|
| 3 |
$ bash ../test.sh <<'EOF' |
| 4 |
> let _ = true || false |
| 5 |
> let _ = true or false |
| 6 |
> EOF |
| 7 |
let _ = |
| 8 |
if true then ( |
| 9 |
___bisect_visit___ 0; |
| 10 |
true) |
| 11 |
else if false then ( |
| 12 |
___bisect_visit___ 1; |
| 13 |
true) |
| 14 |
else false |
| 15 |
|
| 16 |
let _ = |
| 17 |
if true then ( |
| 18 |
___bisect_visit___ 2; |
| 19 |
true) |
| 20 |
else if false then ( |
| 21 |
___bisect_visit___ 3; |
| 22 |
true) |
| 23 |
else false |
| 24 |
|
| 25 |
|
| 26 |
If the right operand is also a logical OR, the instrumentation is "associative" |
| 27 |
rather than nested. |
| 28 |
|
| 29 |
$ bash ../test.sh <<'EOF' |
| 30 |
> let _ = true || true || false |
| 31 |
> let _ = true or true or false |
| 32 |
> EOF |
| 33 |
let _ = |
| 34 |
if true then ( |
| 35 |
___bisect_visit___ 0; |
| 36 |
true) |
| 37 |
else if true then ( |
| 38 |
___bisect_visit___ 1; |
| 39 |
true) |
| 40 |
else if false then ( |
| 41 |
___bisect_visit___ 2; |
| 42 |
true) |
| 43 |
else false |
| 44 |
|
| 45 |
let _ = |
| 46 |
if true then ( |
| 47 |
___bisect_visit___ 3; |
| 48 |
true) |
| 49 |
else if true then ( |
| 50 |
___bisect_visit___ 4; |
| 51 |
true) |
| 52 |
else if false then ( |
| 53 |
___bisect_visit___ 5; |
| 54 |
true) |
| 55 |
else false |
| 56 |
|
| 57 |
|
| 58 |
Recursive instrumentation of subexpressions. |
| 59 |
|
| 60 |
$ bash ../test.sh <<'EOF' |
| 61 |
> let _ = (bool_of_string "true") || (bool_of_string "false") |
| 62 |
> let _ = (bool_of_string "true") or (bool_of_string "false") |
| 63 |
> EOF |
| 64 |
let _ = |
| 65 |
if ___bisect_post_visit___ 3 (bool_of_string "true") then ( |
| 66 |
___bisect_visit___ 0; |
| 67 |
true) |
| 68 |
else if ___bisect_post_visit___ 1 (bool_of_string "false") then ( |
| 69 |
___bisect_visit___ 2; |
| 70 |
true) |
| 71 |
else false |
| 72 |
|
| 73 |
let _ = |
| 74 |
if ___bisect_post_visit___ 7 (bool_of_string "true") then ( |
| 75 |
___bisect_visit___ 4; |
| 76 |
true) |
| 77 |
else if ___bisect_post_visit___ 5 (bool_of_string "false") then ( |
| 78 |
___bisect_visit___ 6; |
| 79 |
true) |
| 80 |
else false |
| 81 |
|
| 82 |
|
| 83 |
Function calls on the right in tail position remain in tail position. Any |
| 84 |
would-be surrounding instrumentation is suppressed. |
| 85 |
|
| 86 |
$ bash ../test.sh <<'EOF' |
| 87 |
> let f _ = (bool_of_string "true") || (bool_of_string "false") |
| 88 |
> let g _ = |
| 89 |
> (bool_of_string "true") or ((bool_of_string [@ocaml.tailcall]) "false") |
| 90 |
> EOF |
| 91 |
let f _ = |
| 92 |
___bisect_visit___ 2; |
| 93 |
if ___bisect_post_visit___ 1 (bool_of_string "true") then ( |
| 94 |
___bisect_visit___ 0; |
| 95 |
true) |
| 96 |
else bool_of_string "false" |
| 97 |
|
| 98 |
let g _ = |
| 99 |
___bisect_visit___ 5; |
| 100 |
if ___bisect_post_visit___ 4 (bool_of_string "true") then ( |
| 101 |
___bisect_visit___ 3; |
| 102 |
true) |
| 103 |
else (bool_of_string [@ocaml.tailcall]) "false" |
| 104 |
|
| 105 |
|
| 106 |
Surrounding instrumentation is still generated when the second function is a |
| 107 |
well-known trivial function. |
| 108 |
|
| 109 |
$ bash ../test.sh <<'EOF' |
| 110 |
> let f _ = (bool_of_string "true") || (true <> false) |
| 111 |
> EOF |
| 112 |
let f _ = |
| 113 |
___bisect_visit___ 3; |
| 114 |
if ___bisect_post_visit___ 2 (bool_of_string "true") then ( |
| 115 |
___bisect_visit___ 0; |
| 116 |
true) |
| 117 |
else if true <> false then ( |
| 118 |
___bisect_visit___ 1; |
| 119 |
true) |
| 120 |
else false |