PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/cpp_namespace_runme.rb

#
Ruby | 62 lines | 39 code | 14 blank | 9 comment | 20 complexity | fc83da01607e4208ec3d3c916bdaed8a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. #!/usr/bin/env ruby
  2. #
  3. # Put description here
  4. #
  5. #
  6. #
  7. #
  8. #
  9. require 'swig_assert'
  10. # Note: This example assumes that namespaces are flattened
  11. require 'cpp_namespace'
  12. n = Cpp_namespace.fact(4)
  13. if n != 24
  14. raise "Bad return value!"
  15. end
  16. if Cpp_namespace.Foo != 42
  17. raise "Bad variable value!"
  18. end
  19. t = Cpp_namespace::Test.new
  20. if t.method() != "Test::method"
  21. raise "Bad method return value!"
  22. end
  23. if Cpp_namespace.do_method(t) != "Test::method"
  24. raise "Bad return value!"
  25. end
  26. if Cpp_namespace.do_method2(t) != "Test::method"
  27. raise "Bad return value!"
  28. end
  29. Cpp_namespace.weird("hello", 4)
  30. t2 = Cpp_namespace::Test2.new
  31. t3 = Cpp_namespace::Test3.new
  32. t4 = Cpp_namespace::Test4.new
  33. t5 = Cpp_namespace::Test5.new
  34. if Cpp_namespace.foo3(42) != 42
  35. raise "Bad return value!"
  36. end
  37. if Cpp_namespace.do_method3(t2, 40) != "Test2::method"
  38. raise "Bad return value!"
  39. end
  40. if Cpp_namespace.do_method3(t3, 40) != "Test3::method"
  41. raise "Bad return value!"
  42. end
  43. if Cpp_namespace.do_method3(t4, 40) != "Test4::method"
  44. raise "Bad return value!"
  45. end
  46. if Cpp_namespace.do_method3(t5, 40) != "Test5::method"
  47. raise "Bad return value!"
  48. end