PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Ruby | 33 lines | 12 code | 7 blank | 14 comment | 8 complexity | b185d1d196966ca36d05245899e545f3 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 'virtual_poly'
  11. d = Virtual_poly::NDouble.new(3.5)
  12. i = Virtual_poly::NInt.new(2)
  13. #
  14. # polymorphic return type working
  15. #
  16. dc = d.copy
  17. ic = i.copy
  18. raise RuntimeError if d.get != dc.get
  19. raise RuntimeError if i.get != ic.get
  20. #
  21. # 'narrowing' working ('nnumber' returns a NNumber)
  22. #
  23. ddc = Virtual_poly::NDouble.narrow(dc.nnumber)
  24. raise RuntimeError if d.get != ddc.get
  25. dic = Virtual_poly::NInt.narrow(ic.nnumber)
  26. raise RuntimeError if i.get != dic.get