1
2
3
4
5
6
7 package main
8
9 import "fmt"
10
11 func main() {
12 var i, k int
13 var r string
14 outer:
15 for k = 0; k < 2; k++ {
16 r += fmt.Sprintln("outer loop top k", k)
17 if k != 0 {
18 panic("k not zero")
19 }
20 for i = 0; i < 2; i++ {
21 if i != 0 {
22 panic("i not zero")
23 }
24 r += fmt.Sprintln("inner loop top i", i)
25 if true {
26 r += "do break\n"
27 break outer
28 }
29 }
30 }
31 r += "broke\n"
32 expect := `outer loop top k 0
33 inner loop top i 0
34 do break
35 broke
36 `
37 if r != expect {
38 panic(r)
39 }
40 }
41
View as plain text