PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms 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
 1#!/usr/bin/env ruby
 2#
 3# Put script description here.
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11require 'anonymous_bitfield'
12
13include Anonymous_bitfield
14
15foo = Foo.new
16
17{'x' => 4,
18  'y' => 3,
19  'f' => 1,
20  'z' => 8,
21  'seq' => 3 }.each do |m, v|
22  foo.send("#{m}=", v)
23  val = foo.send(m)
24  swig_assert("val == v", binding)
25end
26
27{'x' => (1 << 4),
28  'y' => (1 << 4),
29  'f' => (1 << 1),
30  'z' => (1 << 16),
31  'seq' => (1 << (4*8-6)) }.each do |m, v|
32  foo.send("#{m}=", v)
33  val = foo.send(m)
34  swig_assert("val != v", binding)
35end