1 // $G $F.go && $L $F.$A && ./$A.out
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.
9 type T struct { i int; f float; s string; next *T }
11 type R struct { num int }
20 for i := 0; i < len(a); i++ {
21 if a[i].num != i { panic("bad") }
25 type P struct { a, b int };
26 func NewP(a, b int) *P {
32 t = T{0, 7.2, "hi", &t};
35 tp = &T{0, 7.2, "hi", &t};
38 if len(a1) != 3 { panic("a1") }
40 if len(a2) != 10 || cap(a2) != 10 { panic("a2") }
41 //a3 := [10]int{1,2,3,}; // BUG: trailing commas not allowed
42 //if len(a3) != 10 || a2[3] != 0 { panic("a3") }
46 if len(oai) != 3 { panic("oai") }
48 at := []*T{&t, &t, &t};
49 if len(at) != 3 { panic("at") }
52 ac := []chan int{c, c, c};
53 if len(ac) != 3 { panic("ac") }
55 aat := [][len(at)]*T{at, at};
56 if len(aat) != 2 || len(aat[1]) != 3 { panic("at") }
58 s := string([]byte{'h', 'e', 'l', 'l', 'o'});
59 if s != "hello" { panic("s") }
61 m := map[string]float{"one":1.0, "two":2.0, "pi":22./7.};
62 if len(m) != 3 { panic("m") }
64 eq(&[]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)});
68 if p1 == p2 { panic("NewP") }