PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Ruby | 61 lines | 35 code | 11 blank | 15 comment | 2 complexity | 67f4bd9b2540309141aef2d70f0ac3a0 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 script description here.
  4. #
  5. #
  6. #
  7. #
  8. #
  9. require 'swig_assert'
  10. require 'apply_strings'
  11. include Apply_strings
  12. begin
  13. x = UcharPtr.new
  14. swig_assert( fail, "UcharPtr should not be defined")
  15. rescue NameError
  16. end
  17. ptr = 'a'
  18. ['UCharFunction', 'SCharFunction', 'CUCharFunction',
  19. 'CSCharFunction'].each do |m|
  20. val = Apply_strings.send(m, ptr)
  21. swig_assert( "val == ptr", binding )
  22. end
  23. ['CharFunction', 'CCharFunction'].each do |m|
  24. begin
  25. val = Apply_strings.send(m, ptr)
  26. swig_assert( false, nil, "Apply_strings.#{m} should raise TypeError" )
  27. rescue TypeError
  28. end
  29. end
  30. ptr = 'a'
  31. foo = DirectorTest.new
  32. ['UCharFunction', 'SCharFunction', 'CUCharFunction',
  33. 'CSCharFunction'].each do |m|
  34. val = foo.send(m, ptr)
  35. swig_assert( "val == ptr", binding, "DirectorTest.#{m}" )
  36. end
  37. ['CharFunction', 'CCharFunction'].each do |m|
  38. begin
  39. val = foo.send(m, ptr)
  40. swig_assert( false, nil, "DirectorTest.#{m} should raise TypeError" )
  41. rescue TypeError
  42. end
  43. end
  44. # ary = Apply_strings.DigitsGlobalB
  45. # { 0 => 'A',
  46. # 1 => 'B',
  47. # 2 => 'B' }.each do |k,v|
  48. # val = ary[k]
  49. # swig_assert( val == v, "Apply_strings.DigitsGlobalB[#{k}] #{val} != #{v}")
  50. # end