import source from 1.3.40
[external/swig.git] / Examples / test-suite / python / cpp_namespace_runme.py
1 # Note: This example assumes that namespaces are flattened
2 import cpp_namespace
3
4 n = cpp_namespace.fact(4)
5 if n != 24:
6     raise RuntimeError("Bad return value!")
7
8 if cpp_namespace.cvar.Foo != 42:
9     raise RuntimeError("Bad variable value!")
10
11 t = cpp_namespace.Test()
12 if t.method() != "Test::method":
13     raise RuntimeError("Bad method return value!")
14
15 if cpp_namespace.do_method(t) != "Test::method":
16     raise RuntimeError("Bad return value!")
17
18 if cpp_namespace.do_method2(t) != "Test::method":
19     raise RuntimeError("Bad return value!")
20     
21 cpp_namespace.weird("hello", 4)
22
23 del t
24
25 t2 = cpp_namespace.Test2()
26 t3 = cpp_namespace.Test3()
27 t4 = cpp_namespace.Test4()
28 t5 = cpp_namespace.Test5()
29
30 if cpp_namespace.foo3(42) != 42:
31     raise RuntimeError("Bad return value!")
32
33 if cpp_namespace.do_method3(t2,40) != "Test2::method":
34     raise RuntimeError("Bad return value!")
35
36 if cpp_namespace.do_method3(t3,40) != "Test3::method":
37     raise RuntimeError("Bad return value!")
38
39 if cpp_namespace.do_method3(t4,40) != "Test4::method":
40     raise RuntimeError("Bad return value!")
41
42 if cpp_namespace.do_method3(t5,40) != "Test5::method":
43     raise RuntimeError("Bad return value!")
44
45