PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/go/director_nested_runme.go

#
Go | 79 lines | 64 code | 15 blank | 0 comment | 8 complexity | 3679eb02c279b5ff1f674b36312c1706 MD5 | raw file
 1package main
 2
 3import . "./director_nested"
 4
 5type A struct{} // From FooBar_int
 6func (p *A) Do_step() string {
 7	return "A::do_step;"
 8}
 9func (p *A) Get_value() string {
10	return "A::get_value"
11}
12
13func f1() {
14	a := NewDirectorFooBar_int(&A{})
15	if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" {
16		panic("Bad A virtual resolution")
17	}
18}
19
20type B struct{} // From FooBar_int
21func (p *B) Do_advance() string {
22	return "B::do_advance;" + p.Do_step()
23}
24func (p *B) Do_step() string {
25	return "B::do_step;"
26}
27func (p *B) Get_value() int {
28	return 1
29}
30
31func f2() {
32	b := NewDirectorFooBar_int(&B{})
33
34	if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" {
35		panic("Bad B virtual resolution")
36	}
37}
38
39type C struct {
40	fbi FooBar_int
41} // From FooBar_int
42
43func (p *C) Do_advance() string {
44	return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi)
45}
46
47func (p *C) Do_step() string {
48	return "C::do_step;"
49}
50
51func (p *C) Get_value() int {
52	return 2
53}
54
55func (p *C) Get_name() string {
56	return DirectorFooBar_intGet_name(p.fbi) + " hello"
57}
58
59func f3() {
60	m := &C{nil}
61	cc := NewDirectorFooBar_int(m)
62	m.fbi = cc
63	c := FooBar_intGet_self(cc)
64	c.Advance()
65
66	if c.Get_name() != "FooBar::get_name hello" {
67		panic(0)
68	}
69
70	if c.Name() != "FooBar::get_name hello" {
71		panic(0)
72	}
73}
74
75func main() {
76	f1()
77	f2()
78	f3()
79}