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

# · Go · 62 lines · 40 code · 15 blank · 7 comment · 22 complexity · 5bd6fdb03927d97a9d0c29a6a94a6d61 MD5 · raw file

  1. package main
  2. import . "./overload_complicated"
  3. func main() {
  4. var pInt *int
  5. // Check the correct constructors are available
  6. p := NewPop(pInt)
  7. p = NewPop(pInt, false)
  8. // Check overloaded in const only and pointers/references
  9. // which target languages cannot disambiguate
  10. if p.Hip(false) != 701 {
  11. panic("Test 1 failed")
  12. }
  13. if p.Hip(pInt) != 702 {
  14. panic("Test 2 failed")
  15. }
  16. // Reverse the order for the above
  17. if p.Hop(pInt) != 805 {
  18. panic("Test 3 failed")
  19. }
  20. if p.Hop(false) != 801 {
  21. panic("Test 4 failed")
  22. }
  23. // Few more variations and order shuffled
  24. if p.Pop(false) != 901 {
  25. panic("Test 5 failed")
  26. }
  27. if p.Pop(pInt) != 902 {
  28. panic("Test 6 failed")
  29. }
  30. if p.Pop() != 905 {
  31. panic("Test 7 failed")
  32. }
  33. // Overload on const only
  34. if p.Bop(pInt) != 1001 {
  35. panic("Test 8 failed")
  36. }
  37. if p.Bip(pInt) != 2001 {
  38. panic("Test 9 failed")
  39. }
  40. // Globals
  41. if Muzak(false) != 3001 {
  42. panic("Test 10 failed")
  43. }
  44. if Muzak(pInt) != 3002 {
  45. panic("Test 11 failed")
  46. }
  47. }