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

# · Ruby · 48 lines · 22 code · 8 blank · 18 comment · 1 complexity · eae33d13eeca020dfb3bbc2de2905b19 MD5 · raw file

  1. #!/usr/bin/env ruby
  2. #
  3. # Put description here
  4. #
  5. #
  6. #
  7. #
  8. #
  9. require 'swig_assert'
  10. require 'abstract_inherit_ok'
  11. include Abstract_inherit_ok
  12. #
  13. # Shouldn't be able to instantiate Foo, because it declares
  14. # a pure virtual function.
  15. #
  16. exceptionRaised = false
  17. begin
  18. Foo.new
  19. rescue NameError
  20. exceptionRaised = true
  21. rescue TypeError
  22. # In Ruby 1.8 the exception raised is:
  23. # TypeError: allocator undefined for Abstract_inherit_ok::Foo
  24. exceptionRaised = true
  25. ensure
  26. swig_assert( "exceptionRaised", binding )
  27. end
  28. #
  29. # This one's OK since we cleared it with a %feature("notabstract")
  30. # declaration in the interface file.
  31. #
  32. exceptionRaised = false
  33. begin
  34. spam = Spam.new
  35. raise RuntimeError unless spam.blah == 0
  36. rescue NameError
  37. exceptionRaised = true
  38. ensure
  39. swig_assert( "!exceptionRaised", binding )
  40. end