2008-07-15 11:44:02 -06:00
|
|
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2012-01-18 15:31:31 -07:00
|
|
|
import "fmt"
|
|
|
|
|
2008-07-15 11:44:02 -06:00
|
|
|
func main() {
|
2012-01-18 14:20:55 -07:00
|
|
|
var i, k int
|
2012-01-18 15:31:31 -07:00
|
|
|
var r string
|
2012-01-18 14:20:55 -07:00
|
|
|
outer:
|
|
|
|
for k = 0; k < 2; k++ {
|
2012-01-18 15:31:31 -07:00
|
|
|
r += fmt.Sprintln("outer loop top k", k)
|
2012-01-18 14:20:55 -07:00
|
|
|
if k != 0 {
|
|
|
|
panic("k not zero")
|
|
|
|
} // inner loop breaks this one every time
|
|
|
|
for i = 0; i < 2; i++ {
|
|
|
|
if i != 0 {
|
|
|
|
panic("i not zero")
|
|
|
|
} // loop breaks every time
|
2012-01-18 15:31:31 -07:00
|
|
|
r += fmt.Sprintln("inner loop top i", i)
|
2008-07-15 11:44:02 -06:00
|
|
|
if true {
|
2012-01-18 15:31:31 -07:00
|
|
|
r += "do break\n"
|
2012-01-18 14:20:55 -07:00
|
|
|
break outer
|
2008-07-15 11:44:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-18 15:31:31 -07:00
|
|
|
r += "broke\n"
|
|
|
|
expect := `outer loop top k 0
|
|
|
|
inner loop top i 0
|
|
|
|
do break
|
|
|
|
broke
|
|
|
|
`
|
|
|
|
if r != expect {
|
|
|
|
panic(r)
|
|
|
|
}
|
2008-07-15 11:44:02 -06:00
|
|
|
}
|