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

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

#
Go | 50 lines | 37 code | 10 blank | 3 comment | 18 complexity | e55f9e8473a639b9832755fc199640ed MD5 | raw file
 1package main
 2
 3import "./friends"
 4
 5func main() {
 6	a := friends.NewA(2)
 7
 8	if friends.Get_val1(a).(int) != 2 {
 9		panic(0)
10	}
11	if friends.Get_val2(a) != 4 {
12		panic(0)
13	}
14	if friends.Get_val3(a) != 6 {
15		panic(0)
16	}
17
18	// nice overload working fine
19	if friends.Get_val1(1, 2, 3).(int) != 1 {
20		panic(0)
21	}
22
23	b := friends.NewB(3)
24
25	// David's case
26	if friends.Mix(a, b) != 5 {
27		panic(0)
28	}
29
30	di := friends.NewD_d(2)
31	dd := friends.NewD_d(3.3)
32
33	// incredible template overloading working just fine
34	if friends.Get_val1(di).(float64) != 2 {
35		panic(0)
36	}
37	if friends.Get_val1(dd).(float64) != 3.3 {
38		panic(0)
39	}
40
41	friends.Set(di, 4.0)
42	friends.Set(dd, 1.3)
43
44	if friends.Get_val1(di).(float64) != 4 {
45		panic(0)
46	}
47	if friends.Get_val1(dd).(float64) != 1.3 {
48		panic(0)
49	}
50}