PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Go | 125 lines | 93 code | 31 blank | 1 comment | 50 complexity | b5a50ee7b7ae7b0ddff66a7a93d14f2f MD5 | raw file
  1package main
  2
  3import . "./overload_simple"
  4
  5func main() {
  6	if Foo(3) != "foo:int" {
  7		panic("foo(int)")
  8	}
  9
 10	if Foo(3.0) != "foo:double" {
 11		panic("foo(double)")
 12	}
 13
 14	if Foo("hello") != "foo:char *" {
 15		panic("foo(char *)")
 16	}
 17
 18	f := NewFoos()
 19	b := NewBar()
 20
 21	if Foo(f) != "foo:Foo *" {
 22		panic("foo(Foo *)")
 23	}
 24
 25	if Foo(b) != "foo:Bar *" {
 26		panic("foo(Bar *)")
 27	}
 28
 29	v := Malloc_void(32)
 30
 31	if Foo(v) != "foo:void *" {
 32		panic("foo(void *)")
 33	}
 34	s := NewSpam()
 35
 36	if s.Foo(3) != "foo:int" {
 37		panic("Spam::foo(int)")
 38	}
 39
 40	if s.Foo(3.0) != "foo:double" {
 41		panic("Spam::foo(double)")
 42	}
 43
 44	if s.Foo("hello") != "foo:char *" {
 45		panic("Spam::foo(char *)")
 46	}
 47
 48	if s.Foo(f) != "foo:Foo *" {
 49		panic("Spam::foo(Foo *)")
 50	}
 51
 52	if s.Foo(b) != "foo:Bar *" {
 53		panic("Spam::foo(Bar *)")
 54	}
 55
 56	if s.Foo(v) != "foo:void *" {
 57		panic("Spam::foo(void *)")
 58	}
 59
 60	if SpamBar(3) != "bar:int" {
 61		panic("Spam::bar(int)")
 62	}
 63
 64	if SpamBar(3.0) != "bar:double" {
 65		panic("Spam::bar(double)")
 66	}
 67
 68	if SpamBar("hello") != "bar:char *" {
 69		panic("Spam::bar(char *)")
 70	}
 71
 72	if SpamBar(f) != "bar:Foo *" {
 73		panic("Spam::bar(Foo *)")
 74	}
 75
 76	if SpamBar(b) != "bar:Bar *" {
 77		panic("Spam::bar(Bar *)")
 78	}
 79
 80	if SpamBar(v) != "bar:void *" {
 81		panic("Spam::bar(void *)")
 82	}
 83
 84	// Test constructors
 85
 86	s = NewSpam()
 87	if s.GetXtype() != "none" {
 88		panic("Spam()")
 89	}
 90
 91	s = NewSpam(3)
 92	if s.GetXtype() != "int" {
 93		panic("Spam(int)")
 94	}
 95
 96	s = NewSpam(3.4)
 97	if s.GetXtype() != "double" {
 98		panic("Spam(double)")
 99	}
100
101	s = NewSpam("hello")
102	if s.GetXtype() != "char *" {
103		panic("Spam(char *)")
104	}
105
106	s = NewSpam(f)
107	if s.GetXtype() != "Foo *" {
108		panic("Spam(Foo *)")
109	}
110
111	s = NewSpam(b)
112	if s.GetXtype() != "Bar *" {
113		panic("Spam(Bar *)")
114	}
115
116	s = NewSpam(v)
117	if s.GetXtype() != "void *" {
118		panic("Spam(void *)")
119	}
120
121	Free_void(v)
122
123	a := NewClassA()
124	_ = a.Method1(1)
125}