From dc19d168a3e1150e76e8606b75fa3a9cdc4a13d5 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 5 Feb 2006 15:10:01 +0000 Subject: test small structs. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_struct.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 94a175420..e66dd8f05 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -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 -- cgit