summaryrefslogtreecommitdiff
path: root/Examples/python/import/runme.py
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2009-08-18 20:56:02 +0000
committerLorry <lorry@roadtrain.codethink.co.uk>2012-09-25 16:59:08 +0000
commit9f8a09ed743cedd9547bf0661d518647966ab114 (patch)
tree9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/python/import/runme.py
downloadswig-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/runme.py')
-rw-r--r--Examples/python/import/runme.py111
1 files changed, 111 insertions, 0 deletions
diff --git a/Examples/python/import/runme.py b/Examples/python/import/runme.py
new file mode 100644
index 0000000..6b800ec
--- /dev/null
+++ b/Examples/python/import/runme.py
@@ -0,0 +1,111 @@
+# file: runme.py
+# Test various properties of classes defined in separate modules
+
+print "Testing the %import directive"
+import base
+import foo
+import bar
+import spam
+
+# Create some objects
+
+print "Creating some objects"
+
+a = base.Base()
+b = foo.Foo()
+c = bar.Bar()
+d = spam.Spam()
+
+# 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.Foo_fromBase(x)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+print " Spam -> Base -> Bar : ",
+y = bar.Bar_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Spam -> Base -> Spam : ",
+y = spam.Spam_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Foo -> Spam : ",
+y = spam.Spam_fromBase(b)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+
+
+