modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/ken/simpswitch.go (about)

     1  // run
     2  
     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.
     6  
     7  // Test simple switch.
     8  
     9  package main
    10  
    11  func main() {
    12  	r := ""
    13  	a := 3
    14  	for i := 0; i < 10; i = i + 1 {
    15  		switch i {
    16  		case 5:
    17  			r += "five"
    18  		case a, 7:
    19  			r += "a"
    20  		default:
    21  			r += string(i + '0')
    22  		}
    23  		r += "out" + string(i+'0')
    24  	}
    25  	if r != "0out01out12out2aout34out4fiveout56out6aout78out89out9" {
    26  		panic(r)
    27  	}
    28  }