github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/bug236.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  package main
     8  
     9  var gen = 'a'
    10  
    11  func f(n int) string {
    12  	s := string(gen) + string(n+'A'-1)
    13  	gen++
    14  	return s
    15  }
    16  
    17  func g(x, y string) string { return x + y }
    18  
    19  var v1 = f(1) + f(2)
    20  var v2 = g(f(3), f(4))
    21  var v3 = f(5) + f(6) + f(7) + f(8) + f(9)
    22  
    23  func main() {
    24  	gen = 'a'
    25  
    26  	if v1 != "aAbB" {
    27  		panic("BUG: bug236a")
    28  	}
    29  	if v2 != "cCdD" {
    30  		panic("BUG: bug236b")
    31  	}
    32  	if v3 != "eEfFgGhHiI" {
    33  		panic("BUG: bug236c")
    34  	}
    35  
    36  	switch "aAbB" {
    37  	case f(1) + f(2):
    38  	default:
    39  		panic("BUG: bug236d")
    40  	}
    41  
    42  	switch "cCdD" {
    43  	case g(f(3), f(4)):
    44  	default:
    45  		panic("BUG: bug236e")
    46  	}
    47  
    48  	switch "eEfFgGhHiI" {
    49  	case f(5) + f(6) + f(7) + f(8) + f(9):
    50  	default:
    51  		panic("BUG: bug236f")
    52  	}
    53  }