...
Run Format

Source file test/fixedbugs/bug262.go

Documentation: test/fixedbugs

     1  // run
     2  
     3  // Copyright 2010 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  import (
    10  	"errors"
    11  	"strconv"
    12  )
    13  
    14  var trace string
    15  
    16  func f() string {
    17  	trace += "f"
    18  	return "abc"
    19  }
    20  
    21  func g() *error {
    22  	trace += "g"
    23  	var x error
    24  	return &x
    25  }
    26  
    27  func h() string {
    28  	trace += "h"
    29  	return "123"
    30  }
    31  
    32  func i() *int {
    33  	trace += "i"
    34  	var i int
    35  	return &i
    36  }
    37  
    38  func main() {
    39  	m := make(map[string]int)
    40  	m[f()], *g() = strconv.Atoi(h())
    41  	if m["abc"] != 123 || trace != "fgh" {
    42  		println("BUG", m["abc"], trace)
    43  		panic("fail")
    44  	}
    45  	mm := make(map[string]error)
    46  	trace = ""
    47  	mm["abc"] = errors.New("invalid")
    48  	*i(), mm[f()] = strconv.Atoi(h())
    49  	if mm["abc"] != nil || trace != "ifh" {
    50  		println("BUG1", mm["abc"], trace)
    51  		panic("fail")
    52  	}
    53  }
    54  

View as plain text