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

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

#
Ruby | 45 lines | 28 code | 9 blank | 8 comment | 8 complexity | 43e3ee8051b3571df0612bc5accf7166 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_protected'
  11. NoProtectedError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
  12. class FooBar < Director_protected::Bar
  13. protected
  14. def ping
  15. "FooBar::ping();"
  16. end
  17. end
  18. class Hello < FooBar
  19. public
  20. def pang
  21. ping
  22. end
  23. end
  24. b = Director_protected::Bar.new
  25. fb = FooBar.new
  26. p = 0
  27. begin
  28. b.ping
  29. p = 1
  30. rescue NoProtectedError
  31. end
  32. h = Hello.new
  33. raise RuntimeError if p == 1
  34. raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();"
  35. raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();"
  36. raise RuntimeError if h.pang != "FooBar::ping();"