PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. package main
  2. import . "./director_nested"
  3. type A struct{} // From FooBar_int
  4. func (p *A) Do_step() string {
  5. return "A::do_step;"
  6. }
  7. func (p *A) Get_value() string {
  8. return "A::get_value"
  9. }
  10. func f1() {
  11. a := NewDirectorFooBar_int(&A{})
  12. if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" {
  13. panic("Bad A virtual resolution")
  14. }
  15. }
  16. type B struct{} // From FooBar_int
  17. func (p *B) Do_advance() string {
  18. return "B::do_advance;" + p.Do_step()
  19. }
  20. func (p *B) Do_step() string {
  21. return "B::do_step;"
  22. }
  23. func (p *B) Get_value() int {
  24. return 1
  25. }
  26. func f2() {
  27. b := NewDirectorFooBar_int(&B{})
  28. if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" {
  29. panic("Bad B virtual resolution")
  30. }
  31. }
  32. type C struct {
  33. fbi FooBar_int
  34. } // From FooBar_int
  35. func (p *C) Do_advance() string {
  36. return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi)
  37. }
  38. func (p *C) Do_step() string {
  39. return "C::do_step;"
  40. }
  41. func (p *C) Get_value() int {
  42. return 2
  43. }
  44. func (p *C) Get_name() string {
  45. return DirectorFooBar_intGet_name(p.fbi) + " hello"
  46. }
  47. func f3() {
  48. m := &C{nil}
  49. cc := NewDirectorFooBar_int(m)
  50. m.fbi = cc
  51. c := FooBar_intGet_self(cc)
  52. c.Advance()
  53. if c.Get_name() != "FooBar::get_name hello" {
  54. panic(0)
  55. }
  56. if c.Name() != "FooBar::get_name hello" {
  57. panic(0)
  58. }
  59. }
  60. func main() {
  61. f1()
  62. f2()
  63. f3()
  64. }