PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Go | 62 lines | 46 code | 16 blank | 0 comment | 10 complexity | 34fbd641b37814013c5da3cecd1ff789 MD5 | raw file
 1package main
 2
 3import "./director_abstract"
 4
 5type MyFoo struct{}
 6
 7func (p *MyFoo) Ping() string {
 8	return "MyFoo::ping()"
 9}
10
11func f1() {
12	a := director_abstract.NewDirectorFoo(&MyFoo{})
13
14	if a.Ping() != "MyFoo::ping()" {
15		panic(a.Ping())
16	}
17
18	if a.Pong() != "Foo::pong();MyFoo::ping()" {
19		panic(a.Pong())
20	}
21}
22
23type MyExample1 struct{}
24
25func (p *MyExample1) Color(r, g, b byte) int {
26	return int(r)
27}
28
29type MyExample2 struct{}
30
31func (p *MyExample2) Color(r, g, b byte) int {
32	return int(g)
33}
34
35type MyExample3 struct{}
36
37func (p *MyExample3) Color(r, g, b byte) int {
38	return int(b)
39}
40
41func f2() {
42	me1 := director_abstract.NewDirectorExample1(&MyExample1{})
43	if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 {
44		println(director_abstract.Example1Get_color(me1, 1, 2, 3))
45		panic(0)
46	}
47
48	me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2)
49	if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 {
50		panic(0)
51	}
52
53	me3 := director_abstract.NewDirectorExample3_i(&MyExample3{})
54	if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 {
55		panic(0)
56	}
57}
58
59func main() {
60	f1()
61	f2()
62}