| 1 |
// Command panic exercises a panic-terminated basic block (panic ends a block, |
| 2 |
// so statements before and after it are separate edges) and the recovery path. |
| 3 |
// Side-effect free and argv-driven: |
| 4 |
// |
| 5 |
// program boom // takes the panic; the post-panic edge must NOT fire |
| 6 |
// program ok // no panic; the post-panic edge fires |
| 7 |
package main |
| 8 |
|
| 9 |
import "os" |
| 10 |
|
| 11 |
var sink int |
| 12 |
|
| 13 |
func run(boom bool) { |
| 14 |
sink = 1 |
| 15 |
if boom { |
| 16 |
panic("boom") |
| 17 |
} |
| 18 |
sink = 2 |
| 19 |
} |
| 20 |
|
| 21 |
func main() { |
| 22 |
defer func() { _ = recover() }() |
| 23 |
run(os.Args[1] == "boom") |
| 24 |
} |