PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/perl5/import/runme.pl

#
Perl | 116 lines | 82 code | 28 blank | 6 comment | 8 complexity | 297715360f1cbc00f657ad7b7e83e33f MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme.pl
  2. # Test various properties of classes defined in separate modules
  3. print "Testing the %import directive\n";
  4. use baseclass;
  5. use foo;
  6. use bar;
  7. use spam;
  8. # Create some objects
  9. print "Creating some objects\n";
  10. $a = new baseclass::Base();
  11. $b = new foo::Foo();
  12. $c = new bar::Bar();
  13. $d = new spam::Spam();
  14. # Try calling some methods
  15. print "Testing some methods\n";
  16. print "Should see 'Base::A' ---> ";
  17. $a->A();
  18. print "Should see 'Base::B' ---> ";
  19. $a->B();
  20. print "Should see 'Foo::A' ---> ";
  21. $b->A();
  22. print "Should see 'Foo::B' ---> ";
  23. $b->B();
  24. print "Should see 'Bar::A' ---> ";
  25. $c->A();
  26. print "Should see 'Bar::B' ---> ";
  27. $c->B();
  28. print "Should see 'Spam::A' ---> ";
  29. $d->A();
  30. print "Should see 'Spam::B' ---> ";
  31. $d->B();
  32. # Try some casts
  33. print "\nTesting some casts\n";
  34. $x = $a->toBase();
  35. print "Should see 'Base::A' ---> ";
  36. $x->A();
  37. print "Should see 'Base::B' ---> ";
  38. $x->B();
  39. $x = $b->toBase();
  40. print "Should see 'Foo::A' ---> ";
  41. $x->A();
  42. print "Should see 'Base::B' ---> ";
  43. $x->B();
  44. $x = $c->toBase();
  45. print "Should see 'Bar::A' ---> ";
  46. $x->A();
  47. print "Should see 'Base::B' ---> ";
  48. $x->B();
  49. $x = $d->toBase();
  50. print "Should see 'Spam::A' ---> ";
  51. $x->A();
  52. print "Should see 'Base::B' ---> ";
  53. $x->B();
  54. $x = $d->toBar();
  55. print "Should see 'Bar::B' ---> ";
  56. $x->B();
  57. print "\nTesting some dynamic casts\n";
  58. $x = $d->toBase();
  59. print " Spam -> Base -> Foo : ";
  60. $y = foo::Foo::fromBase($x);
  61. if ($y) {
  62. print "bad swig\n";
  63. } else {
  64. print "good swig\n";
  65. }
  66. print " Spam -> Base -> Bar : ";
  67. $y = bar::Bar::fromBase($x);
  68. if ($y) {
  69. print "good swig\n";
  70. } else {
  71. print "bad swig\n";
  72. }
  73. print " Spam -> Base -> Spam : ";
  74. $y = spam::Spam::fromBase($x);
  75. if ($y) {
  76. print "good swig\n";
  77. } else {
  78. print "bad swig\n";
  79. }
  80. print " Foo -> Spam : ";
  81. #print $b;
  82. $y = spam::Spam::fromBase($b);
  83. print $y;
  84. if ($y) {
  85. print "bad swig\n";
  86. } else {
  87. print "good swig\n";
  88. }