blob: 6dd7d67dc37bcf57a309548e21ca3aa093768ac8 [file] [log] [blame]
Russ Coxd5269d02009-05-21 14:46:13 -07001// $G $D/$F.go && $L $F.$A && ./$A.out
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
7package main
8
9import "fmt"
10import "reflect"
11
12type S struct {
Rob Pike4f61fc92010-09-04 10:36:13 +100013 A, B, C, X, Y, Z int
Russ Coxd5269d02009-05-21 14:46:13 -070014}
15
16type T struct {
Rob Pike4f61fc92010-09-04 10:36:13 +100017 S
Russ Coxd5269d02009-05-21 14:46:13 -070018}
19
20var a1 = S { 0, 0, 0, 1, 2, 3 }
21var b1 = S { X: 1, Z: 3, Y: 2 }
22
23var a2 = S { 0, 0, 0, 0, 0, 0, }
Russ Coxc2fa45b2009-05-21 16:31:10 -070024var b2 = S { }
Russ Coxd5269d02009-05-21 14:46:13 -070025
26var a3 = T { S { 1, 2, 3, 0, 0, 0, } }
Russ Coxc2fa45b2009-05-21 16:31:10 -070027var b3 = T { S: S{ A: 1, B: 2, C: 3 } }
Russ Coxd5269d02009-05-21 14:46:13 -070028
29var a4 = &[16]byte { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
30var b4 = &[16]byte { 4: 1, 1, 1, 1, 12: 1, 1, }
31
32var a5 = &[16]byte { 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
33var b5 = &[16]byte { 1, 4: 1, 1, 1, 1, 12: 1, 1, }
34
35var a6 = &[16]byte { 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
Russ Coxc2fa45b2009-05-21 16:31:10 -070036var b6 = &[...]byte { 1, 4: 1, 1, 1, 1, 12: 1, 1, 0, 0,}
Russ Coxd5269d02009-05-21 14:46:13 -070037
38type Same struct {
39 a, b interface{}
40}
41
42var same = []Same {
43 Same{ a1, b1 },
44 Same{ a2, b2 },
45 Same{ a3, b3 },
46 Same{ a4, b4 },
47 Same{ a5, b5 },
48 Same{ a6, b6 },
49}
50
51func main() {
Rob Pike4f61fc92010-09-04 10:36:13 +100052 ok := true
Russ Coxae54cf72009-09-15 12:42:24 -070053 for _, s := range same {
Russ Coxd5269d02009-05-21 14:46:13 -070054 if !reflect.DeepEqual(s.a, s.b) {
Rob Pike4f61fc92010-09-04 10:36:13 +100055 ok = false
56 fmt.Printf("not same: %v and %v\n", s.a, s.b)
Russ Coxd5269d02009-05-21 14:46:13 -070057 }
58 }
59 if !ok {
Rob Pike4f61fc92010-09-04 10:36:13 +100060 fmt.Println("BUG: test/initialize")
Russ Coxd5269d02009-05-21 14:46:13 -070061 }
62}