PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. package main
  2. import "./friends"
  3. func main() {
  4. a := friends.NewA(2)
  5. if friends.Get_val1(a).(int) != 2 {
  6. panic(0)
  7. }
  8. if friends.Get_val2(a) != 4 {
  9. panic(0)
  10. }
  11. if friends.Get_val3(a) != 6 {
  12. panic(0)
  13. }
  14. // nice overload working fine
  15. if friends.Get_val1(1, 2, 3).(int) != 1 {
  16. panic(0)
  17. }
  18. b := friends.NewB(3)
  19. // David's case
  20. if friends.Mix(a, b) != 5 {
  21. panic(0)
  22. }
  23. di := friends.NewD_d(2)
  24. dd := friends.NewD_d(3.3)
  25. // incredible template overloading working just fine
  26. if friends.Get_val1(di).(float64) != 2 {
  27. panic(0)
  28. }
  29. if friends.Get_val1(dd).(float64) != 3.3 {
  30. panic(0)
  31. }
  32. friends.Set(di, 4.0)
  33. friends.Set(dd, 1.3)
  34. if friends.Get_val1(di).(float64) != 4 {
  35. panic(0)
  36. }
  37. if friends.Get_val1(dd).(float64) != 1.3 {
  38. panic(0)
  39. }
  40. }