mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test small structs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4f245852bc
commit
84aa2febd6
1 changed files with 16 additions and 0 deletions
|
@ -33,4 +33,20 @@ class TestStruct < Test::Unit::TestCase
|
|||
list.pop
|
||||
end
|
||||
end
|
||||
|
||||
def test_small_structs
|
||||
names = [:a, :b, :c, :d]
|
||||
1.upto(4) {|n|
|
||||
fields = names[0, n]
|
||||
klass = Struct.new(*fields)
|
||||
o = klass.new(*(0...n).to_a)
|
||||
fields.each_with_index {|name, i|
|
||||
assert_equal(i, o[name])
|
||||
}
|
||||
o = klass.new(*(0...n).to_a.reverse)
|
||||
fields.each_with_index {|name, i|
|
||||
assert_equal(n-i-1, o[name])
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue