/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Examples/python/import_template/runme.py
Python | 111 lines | 102 code | 5 blank | 4 comment | 0 complexity | 80b54efbeebea95418413ab353359c55 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1# file: runme.py
2# Test various properties of classes defined in separate modules
3
4print "Testing the %import directive with templates"
5import base
6import foo
7import bar
8import spam
9
10# Create some objects
11
12print "Creating some objects"
13
14a = base.intBase()
15b = foo.intFoo()
16c = bar.intBar()
17d = spam.intSpam()
18
19# Try calling some methods
20print "Testing some methods"
21print "",
22print "Should see 'Base::A' ---> ",
23a.A()
24print "Should see 'Base::B' ---> ",
25a.B()
26
27print "Should see 'Foo::A' ---> ",
28b.A()
29print "Should see 'Foo::B' ---> ",
30b.B()
31
32print "Should see 'Bar::A' ---> ",
33c.A()
34print "Should see 'Bar::B' ---> ",
35c.B()
36
37print "Should see 'Spam::A' ---> ",
38d.A()
39print "Should see 'Spam::B' ---> ",
40d.B()
41
42# Try some casts
43
44print "\nTesting some casts\n"
45print "",
46
47x = a.toBase()
48print "Should see 'Base::A' ---> ",
49x.A()
50print "Should see 'Base::B' ---> ",
51x.B()
52
53x = b.toBase()
54print "Should see 'Foo::A' ---> ",
55x.A()
56
57print "Should see 'Base::B' ---> ",
58x.B()
59
60x = c.toBase()
61print "Should see 'Bar::A' ---> ",
62x.A()
63
64print "Should see 'Base::B' ---> ",
65x.B()
66
67x = d.toBase()
68print "Should see 'Spam::A' ---> ",
69x.A()
70
71print "Should see 'Base::B' ---> ",
72x.B()
73
74x = d.toBar()
75print "Should see 'Bar::B' ---> ",
76x.B()
77
78print "\nTesting some dynamic casts\n"
79x = d.toBase()
80
81print " Spam -> Base -> Foo : ",
82y = foo.intFoo_fromBase(x)
83if y:
84 print "bad swig"
85else:
86 print "good swig"
87
88print " Spam -> Base -> Bar : ",
89y = bar.intBar_fromBase(x)
90if y:
91 print "good swig"
92else:
93 print "bad swig"
94
95print " Spam -> Base -> Spam : ",
96y = spam.intSpam_fromBase(x)
97if y:
98 print "good swig"
99else:
100 print "bad swig"
101
102print " Foo -> Spam : ",
103y = spam.intSpam_fromBase(b)
104if y:
105 print "bad swig"
106else:
107 print "good swig"
108
109
110
111