OLD | NEW |
(Empty) | |
| 1 // $G $D/$F.go && $L $F.$A && ./$A.out |
| 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 "os" |
| 11 "strconv" |
| 12 ) |
| 13 |
| 14 var trace string |
| 15 |
| 16 func f() string { |
| 17 trace += "f" |
| 18 return "abc" |
| 19 } |
| 20 |
| 21 func g() *os.Error { |
| 22 trace += "g" |
| 23 var x os.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 |
| 39 func main() { |
| 40 m := make(map[string]int) |
| 41 m[f()], *g() = strconv.Atoi(h()) |
| 42 if m["abc"] != 123 || trace != "fgh" { |
| 43 panic("BUG", m["abc"], trace) |
| 44 } |
| 45 mm := make(map[string]os.Error) |
| 46 trace = "" |
| 47 mm["abc"] = os.EINVAL |
| 48 *i(), mm[f()] = strconv.Atoi(h()) |
| 49 if mm["abc"] != nil || trace != "ifh" { |
| 50 panic("BUG1", mm["abc"], trace) |
| 51 } |
| 52 } |
OLD | NEW |