pass_struct.go raw
1 package main
2
3 type Point struct {
4 X int32
5 Y int32
6 }
7
8 type Mixed struct {
9 A float64
10 B int32
11 C bool
12 D uint8
13 }
14
15 type Nested struct {
16 P Point
17 V int64
18 }
19
20 func wpoint(p Point) {
21 if p.X == 10 && p.Y == 20 {
22 println("PASS:struct-point")
23 } else {
24 println("FAIL:struct-point")
25 }
26 }
27
28 func wmixed(m Mixed) {
29 if m.A == 3.5 && m.B == 99 && m.C && m.D == 7 {
30 println("PASS:struct-mixed")
31 } else {
32 println("FAIL:struct-mixed")
33 }
34 }
35
36 func wnested(n Nested) {
37 if n.P.X == 1 && n.P.Y == 2 && n.V == 42 {
38 println("PASS:struct-nested")
39 } else {
40 println("FAIL:struct-nested")
41 }
42 }
43
44 func main() {
45 spawn(wpoint, Point{X: 10, Y: 20})
46 spawn(wmixed, Mixed{A: 3.5, B: 99, C: true, D: 7})
47 spawn(wnested, Nested{P: Point{X: 1, Y: 2}, V: 42})
48 for i := int32(0); i < 50000000; i++ {
49 }
50 }
51