]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/go.test/test/initialize.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / gcc / testsuite / go.test / test / initialize.go
1 // $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
7 package main
8
9 import "fmt"
10 import "reflect"
11
12 type S struct {
13 A, B, C, X, Y, Z int
14 }
15
16 type T struct {
17 S
18 }
19
20 var a1 = S { 0, 0, 0, 1, 2, 3 }
21 var b1 = S { X: 1, Z: 3, Y: 2 }
22
23 var a2 = S { 0, 0, 0, 0, 0, 0, }
24 var b2 = S { }
25
26 var a3 = T { S { 1, 2, 3, 0, 0, 0, } }
27 var b3 = T { S: S{ A: 1, B: 2, C: 3 } }
28
29 var a4 = &[16]byte { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
30 var b4 = &[16]byte { 4: 1, 1, 1, 1, 12: 1, 1, }
31
32 var a5 = &[16]byte { 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
33 var b5 = &[16]byte { 1, 4: 1, 1, 1, 1, 12: 1, 1, }
34
35 var a6 = &[16]byte { 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, }
36 var b6 = &[...]byte { 1, 4: 1, 1, 1, 1, 12: 1, 1, 0, 0,}
37
38 type Same struct {
39 a, b interface{}
40 }
41
42 var 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
51 func main() {
52 ok := true
53 for _, s := range same {
54 if !reflect.DeepEqual(s.a, s.b) {
55 ok = false
56 fmt.Printf("not same: %v and %v\n", s.a, s.b)
57 }
58 }
59 if !ok {
60 fmt.Println("BUG: test/initialize")
61 }
62 }