PageRenderTime 37ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Ruby | 57 lines | 24 code | 7 blank | 26 comment | 19 complexity | f231f41f6668c2e124597b36d218a0c1 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 'li_std_pair'
  11. include Li_std_pair
  12. swig_assert_each_line(<<'EOF', binding)
  13. #
  14. # Because of template specializations for pair<int, int>, these should return
  15. # an Array of size 2, where both elements are Fixnums.
  16. #
  17. intPair = makeIntPair(7, 6)
  18. intPair.instance_of?(Array)
  19. intPair.size == 2
  20. intPair[0] == 7 && intPair[1] == 6
  21. intPairConstRef = makeIntPairConstRef(7, 6)
  22. intPairConstRef.instance_of?(Array)
  23. intPairConstRef[0] == 7 && intPairConstRef[1] == 6
  24. #
  25. # Each of these should return a reference to a wrapped
  26. # std::pair<int, int> object (i.e. an IntPair instance).
  27. #
  28. intPairPtr = makeIntPairPtr(7, 6)
  29. intPairPtr.instance_of?(IntPair)
  30. intPairPtr[0] == 7 && intPairPtr[1] == 6
  31. intPairRef = makeIntPairRef(7, 6)
  32. intPairRef.instance_of?(IntPair)
  33. intPairRef[0] == 7 && intPairRef[1] == 6
  34. #
  35. # Now test various input typemaps. Each of the wrapped C++ functions
  36. # (product1, product2 and product3) is expecting an argument of a
  37. # different type (see li_std_pair.i). Typemaps should be in place to
  38. # convert this Array into the expected argument type.
  39. #
  40. product1(intPair) == 42
  41. product2(intPair) == 42
  42. product3(intPair) == 42
  43. #
  44. # Similarly, each of the input typemaps should know what to do
  45. # with an IntPair instance.
  46. #
  47. product1(intPairPtr) == 42
  48. product2(intPairPtr) == 42
  49. product3(intPairPtr) == 42
  50. EOF