PageRenderTime 16ms CodeModel.GetById 1ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/python/cpp_namespace_runme.py

#
Python | 45 lines | 29 code | 15 blank | 1 comment | 10 complexity | ef0094798dc39d4c7bb7a3fed0378b8d MD5 | raw file
 1# Note: This example assumes that namespaces are flattened
 2import cpp_namespace
 3
 4n = cpp_namespace.fact(4)
 5if n != 24:
 6    raise RuntimeError("Bad return value!")
 7
 8if cpp_namespace.cvar.Foo != 42:
 9    raise RuntimeError("Bad variable value!")
10
11t = cpp_namespace.Test()
12if t.method() != "Test::method":
13    raise RuntimeError("Bad method return value!")
14
15if cpp_namespace.do_method(t) != "Test::method":
16    raise RuntimeError("Bad return value!")
17
18if cpp_namespace.do_method2(t) != "Test::method":
19    raise RuntimeError("Bad return value!")
20    
21cpp_namespace.weird("hello", 4)
22
23del t
24
25t2 = cpp_namespace.Test2()
26t3 = cpp_namespace.Test3()
27t4 = cpp_namespace.Test4()
28t5 = cpp_namespace.Test5()
29
30if cpp_namespace.foo3(42) != 42:
31    raise RuntimeError("Bad return value!")
32
33if cpp_namespace.do_method3(t2,40) != "Test2::method":
34    raise RuntimeError("Bad return value!")
35
36if cpp_namespace.do_method3(t3,40) != "Test3::method":
37    raise RuntimeError("Bad return value!")
38
39if cpp_namespace.do_method3(t4,40) != "Test4::method":
40    raise RuntimeError("Bad return value!")
41
42if cpp_namespace.do_method3(t5,40) != "Test5::method":
43    raise RuntimeError("Bad return value!")
44
45