3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test switch statements.
13 func assert(cond bool, msg string) {
15 print("assertion fail: ", msg, "\n")
83 assert(false, "default")
94 assert(false, "default")
111 assert(i5 == 5, "good")
158 assert(i5 == 5, "good")
166 fallthrough // tests scoping of cases
207 assert(i5 == 5, "good")
209 assert(fired, "fired")
244 assert(i5 == count, "good")
246 assert(fired, "fired")
250 assert(false, "wowie")
252 assert(true, "hello")
254 assert(false, "jumpn")
256 assert(false, "default")
260 switch i := i5 + 2; i {
264 assert(false, "fail")
268 // switch on nil-only comparison types
269 switch f := func() {}; f {
271 assert(false, "f should not be nil")
275 switch m := make(map[int]int); m {
277 assert(false, "m should not be nil")
281 switch a := make([]int, 1); a {
283 assert(false, "m should not be nil")