2012-02-16 21:50:37 -07:00
|
|
|
// run
|
2008-06-06 15:27:34 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2009-12-10 13:53:23 -07:00
|
|
|
type C struct {
|
2008-06-06 15:27:34 -06:00
|
|
|
a int;
|
2009-01-30 15:39:31 -07:00
|
|
|
x func(p *C)int;
|
2008-06-06 15:27:34 -06:00
|
|
|
}
|
|
|
|
|
2009-12-10 13:53:23 -07:00
|
|
|
func (this *C) f()int {
|
2008-06-06 15:27:34 -06:00
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
func
|
2009-12-10 13:53:23 -07:00
|
|
|
main() {
|
2008-06-06 15:27:34 -06:00
|
|
|
var v int;
|
|
|
|
var c *C;
|
|
|
|
|
2009-01-06 16:19:02 -07:00
|
|
|
c = new(C);
|
2008-06-06 15:27:34 -06:00
|
|
|
c.a = 6;
|
2009-01-30 15:39:31 -07:00
|
|
|
c.x = g;
|
2008-06-06 15:27:34 -06:00
|
|
|
|
|
|
|
v = g(c);
|
2008-08-11 23:07:49 -06:00
|
|
|
if v != 6 { panic(v); }
|
2008-06-06 15:27:34 -06:00
|
|
|
|
|
|
|
v = c.x(c);
|
2008-08-11 23:07:49 -06:00
|
|
|
if v != 6 { panic(v); }
|
2008-06-06 15:27:34 -06:00
|
|
|
|
|
|
|
v = c.f();
|
2008-08-11 23:07:49 -06:00
|
|
|
if v != 6 { panic(v); }
|
2008-06-06 15:27:34 -06:00
|
|
|
}
|
|
|
|
|
2009-12-10 13:53:23 -07:00
|
|
|
func g(p *C)int {
|
2008-06-06 15:27:34 -06:00
|
|
|
var v int;
|
|
|
|
|
|
|
|
v = p.a;
|
2008-08-11 23:07:49 -06:00
|
|
|
if v != 6 { panic(v); }
|
2008-06-06 15:27:34 -06:00
|
|
|
return p.a;
|
|
|
|
}
|