PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Ruby | 70 lines | 43 code | 19 blank | 8 comment | 0 complexity | 26091190ec9a60e58c0c210a415ec66f 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. require 'director_exception'
  11. include Director_exception
  12. class MyFoo < Foo
  13. def ping
  14. raise NotImplementedError, "MyFoo::ping() EXCEPTION"
  15. end
  16. end
  17. class MyFoo2 < Foo
  18. def ping
  19. nil # error: should return a string
  20. end
  21. end
  22. class MyFoo3 < Foo
  23. def ping
  24. 5 # error: should return a string
  25. end
  26. end
  27. ok = false
  28. a = MyFoo.new
  29. b = launder(a)
  30. begin
  31. b.pong
  32. rescue NotImplementedError
  33. ok = true
  34. end
  35. raise RuntimeError unless ok
  36. ok = false
  37. a = MyFoo2.new
  38. b = launder(a)
  39. begin
  40. b.pong
  41. rescue TypeError
  42. ok = true
  43. end
  44. a = MyFoo3.new
  45. b = launder(a)
  46. begin
  47. b.pong
  48. rescue TypeError
  49. ok = true
  50. end
  51. raise RuntimeError unless ok