PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Ruby | 35 lines | 22 code | 5 blank | 8 comment | 2 complexity | 969abc40537fccb6e78ba38b0f0ea104 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 'anonymous_bitfield'
  11. include Anonymous_bitfield
  12. foo = Foo.new
  13. {'x' => 4,
  14. 'y' => 3,
  15. 'f' => 1,
  16. 'z' => 8,
  17. 'seq' => 3 }.each do |m, v|
  18. foo.send("#{m}=", v)
  19. val = foo.send(m)
  20. swig_assert("val == v", binding)
  21. end
  22. {'x' => (1 << 4),
  23. 'y' => (1 << 4),
  24. 'f' => (1 << 1),
  25. 'z' => (1 << 16),
  26. 'seq' => (1 << (4*8-6)) }.each do |m, v|
  27. foo.send("#{m}=", v)
  28. val = foo.send(m)
  29. swig_assert("val != v", binding)
  30. end