diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-08-18 20:56:02 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 16:59:08 +0000 |
commit | 9f8a09ed743cedd9547bf0661d518647966ab114 (patch) | |
tree | 9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/python/import_template/runme.py | |
download | swig-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/python/import_template/runme.py')
-rw-r--r-- | Examples/python/import_template/runme.py | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Examples/python/import_template/runme.py b/Examples/python/import_template/runme.py new file mode 100644 index 0000000..0d5aded --- /dev/null +++ b/Examples/python/import_template/runme.py @@ -0,0 +1,111 @@ +# file: runme.py +# Test various properties of classes defined in separate modules + +print "Testing the %import directive with templates" +import base +import foo +import bar +import spam + +# Create some objects + +print "Creating some objects" + +a = base.intBase() +b = foo.intFoo() +c = bar.intBar() +d = spam.intSpam() + +# Try calling some methods +print "Testing some methods" +print "", +print "Should see 'Base::A' ---> ", +a.A() +print "Should see 'Base::B' ---> ", +a.B() + +print "Should see 'Foo::A' ---> ", +b.A() +print "Should see 'Foo::B' ---> ", +b.B() + +print "Should see 'Bar::A' ---> ", +c.A() +print "Should see 'Bar::B' ---> ", +c.B() + +print "Should see 'Spam::A' ---> ", +d.A() +print "Should see 'Spam::B' ---> ", +d.B() + +# Try some casts + +print "\nTesting some casts\n" +print "", + +x = a.toBase() +print "Should see 'Base::A' ---> ", +x.A() +print "Should see 'Base::B' ---> ", +x.B() + +x = b.toBase() +print "Should see 'Foo::A' ---> ", +x.A() + +print "Should see 'Base::B' ---> ", +x.B() + +x = c.toBase() +print "Should see 'Bar::A' ---> ", +x.A() + +print "Should see 'Base::B' ---> ", +x.B() + +x = d.toBase() +print "Should see 'Spam::A' ---> ", +x.A() + +print "Should see 'Base::B' ---> ", +x.B() + +x = d.toBar() +print "Should see 'Bar::B' ---> ", +x.B() + +print "\nTesting some dynamic casts\n" +x = d.toBase() + +print " Spam -> Base -> Foo : ", +y = foo.intFoo_fromBase(x) +if y: + print "bad swig" +else: + print "good swig" + +print " Spam -> Base -> Bar : ", +y = bar.intBar_fromBase(x) +if y: + print "good swig" +else: + print "bad swig" + +print " Spam -> Base -> Spam : ", +y = spam.intSpam_fromBase(x) +if y: + print "good swig" +else: + print "bad swig" + +print " Foo -> Spam : ", +y = spam.intSpam_fromBase(b) +if y: + print "bad swig" +else: + print "good swig" + + + + |