PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/python/import/runme.py

#
Python | 111 lines | 102 code | 5 blank | 4 comment | 0 complexity | e05725a257bfe6aab6406ae8e77f6fa4 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. print "Testing the %import directive"
  4. import base
  5. import foo
  6. import bar
  7. import spam
  8. # Create some objects
  9. print "Creating some objects"
  10. a = base.Base()
  11. b = foo.Foo()
  12. c = bar.Bar()
  13. d = spam.Spam()
  14. # Try calling some methods
  15. print "Testing some methods"
  16. print "",
  17. print "Should see 'Base::A' ---> ",
  18. a.A()
  19. print "Should see 'Base::B' ---> ",
  20. a.B()
  21. print "Should see 'Foo::A' ---> ",
  22. b.A()
  23. print "Should see 'Foo::B' ---> ",
  24. b.B()
  25. print "Should see 'Bar::A' ---> ",
  26. c.A()
  27. print "Should see 'Bar::B' ---> ",
  28. c.B()
  29. print "Should see 'Spam::A' ---> ",
  30. d.A()
  31. print "Should see 'Spam::B' ---> ",
  32. d.B()
  33. # Try some casts
  34. print "\nTesting some casts\n"
  35. print "",
  36. x = a.toBase()
  37. print "Should see 'Base::A' ---> ",
  38. x.A()
  39. print "Should see 'Base::B' ---> ",
  40. x.B()
  41. x = b.toBase()
  42. print "Should see 'Foo::A' ---> ",
  43. x.A()
  44. print "Should see 'Base::B' ---> ",
  45. x.B()
  46. x = c.toBase()
  47. print "Should see 'Bar::A' ---> ",
  48. x.A()
  49. print "Should see 'Base::B' ---> ",
  50. x.B()
  51. x = d.toBase()
  52. print "Should see 'Spam::A' ---> ",
  53. x.A()
  54. print "Should see 'Base::B' ---> ",
  55. x.B()
  56. x = d.toBar()
  57. print "Should see 'Bar::B' ---> ",
  58. x.B()
  59. print "\nTesting some dynamic casts\n"
  60. x = d.toBase()
  61. print " Spam -> Base -> Foo : ",
  62. y = foo.Foo_fromBase(x)
  63. if y:
  64. print "bad swig"
  65. else:
  66. print "good swig"
  67. print " Spam -> Base -> Bar : ",
  68. y = bar.Bar_fromBase(x)
  69. if y:
  70. print "good swig"
  71. else:
  72. print "bad swig"
  73. print " Spam -> Base -> Spam : ",
  74. y = spam.Spam_fromBase(x)
  75. if y:
  76. print "good swig"
  77. else:
  78. print "bad swig"
  79. print " Foo -> Spam : ",
  80. y = spam.Spam_fromBase(b)
  81. if y:
  82. print "bad swig"
  83. else:
  84. print "good swig"