PageRenderTime 44ms CodeModel.GetById 9ms app.highlight 31ms RepoModel.GetById 1ms app.codeStats 1ms

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

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