Source file
test/ken/ptrfun.go
1
2
3
4
5
6
7
8
9 package main
10
11 type C struct {
12 a int;
13 x func(p *C)int;
14 }
15
16 func (this *C) f()int {
17 return this.a;
18 }
19
20 func
21 main() {
22 var v int;
23 var c *C;
24
25 c = new(C);
26 c.a = 6;
27 c.x = g;
28
29 v = g(c);
30 if v != 6 { panic(v); }
31
32 v = c.x(c);
33 if v != 6 { panic(v); }
34
35 v = c.f();
36 if v != 6 { panic(v); }
37 }
38
39 func g(p *C)int {
40 var v int;
41
42 v = p.a;
43 if v != 6 { panic(v); }
44 return p.a;
45 }
46
View as plain text