PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-15/SWIG/Examples/test-suite/perl5/overload_simple_runme.pl

#
Perl | 120 lines | 87 code | 32 blank | 1 comment | 50 complexity | 540800c7bcfe895343a8b797182fe2cf MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. use overload_simple;
  2. $f = new overload_simple::Foo();
  3. $b = new overload_simple::Bar();
  4. $v = overload_simple::malloc_void(32);
  5. if (overload_simple::foo(3) != "foo:int") {
  6. die("foo(int)");
  7. }
  8. if (overload_simple::foo(3.0) != "foo:double") {
  9. die("foo(double)");
  10. }
  11. if (overload_simple::foo("hello") != "foo:char *") {
  12. die("foo(char *)");
  13. }
  14. if (overload_simple::foo($f) != "foo:Foo *") {
  15. die("foo(Foo *)");
  16. }
  17. if (overload_simple::foo($b) != "foo:Bar *") {
  18. die("foo(Bar *)");
  19. }
  20. if (overload_simple::foo($v) != "foo:void *") {
  21. die("foo(void *)");
  22. }
  23. $s = new overload_simple::Spam();
  24. if ($s->foo(3) != "foo:int") {
  25. die("Spam::foo(int)");
  26. }
  27. if ($s->foo(3.0) != "foo:double") {
  28. die("Spam::foo(double)");
  29. }
  30. if ($s->foo("hello") != "foo:char *") {
  31. die("Spam::foo(char *)");
  32. }
  33. if ($s->foo($f) != "foo:Foo *") {
  34. die("Spam::foo(Foo *)");
  35. }
  36. if ($s->foo($b) != "foo:Bar *") {
  37. die("Spam::foo(Bar *)");
  38. }
  39. if ($s->foo($v) != "foo:void *") {
  40. die("Spam::foo(void *)");
  41. }
  42. if (overload_simple::Spam::bar(3) != "bar:int") {
  43. die("Spam::bar(int)");
  44. }
  45. if (overload_simple::Spam::bar(3.0) != "bar:double") {
  46. die("Spam::bar(double)");
  47. }
  48. if (overload_simple::Spam::bar("hello") != "bar:char *") {
  49. die("Spam::bar(char *)");
  50. }
  51. if (overload_simple::Spam::bar($f) != "bar:Foo *") {
  52. die("Spam::bar(Foo *)");
  53. }
  54. if (overload_simple::Spam::bar($b) != "bar:Bar *") {
  55. die("Spam::bar(Bar *)");
  56. }
  57. if (overload_simple::Spam::bar($v) != "bar:void *") {
  58. die("Spam::bar(void *)");
  59. }
  60. # Test constructors
  61. $s = new overload_simple::Spam();
  62. if ($s->{type} != "none") {
  63. die("Spam()");
  64. }
  65. $s = new overload_simple::Spam(3);
  66. if ($s->{type} != "int") {
  67. die("Spam(int)");
  68. }
  69. $s = new overload_simple::Spam(3.0);
  70. if ($s->{type} != "double") {
  71. die("Spam(double)");
  72. }
  73. $s = new overload_simple::Spam("hello");
  74. if ($s->{type} != "char *") {
  75. die("Spam(char *)");
  76. }
  77. $s = new overload_simple::Spam($f);
  78. if ($s->{type} != "Foo *") {
  79. die("Spam(Foo *)");
  80. }
  81. $s = new overload_simple::Spam($b);
  82. if ($s->{type} != "Bar *") {
  83. die("Spam(Bar *)");
  84. }
  85. $s = new overload_simple::Spam($v);
  86. if ($s->{type} != "void *") {
  87. die("Spam(void *)");
  88. }