aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_struct.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-05 15:10:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-05 15:10:01 +0000
commit84aa2febd665e9d9457361b5198281d0e6b2d863 (patch)
treef88b5328d33e9564acde729578bf1c14c70f57bc /test/ruby/test_struct.rb
parent4f245852bc12454674e9f9efe52a009a682389e2 (diff)
downloadruby-84aa2febd665e9d9457361b5198281d0e6b2d863.tar.gz
test small structs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r--test/ruby/test_struct.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 94a175420b..e66dd8f05b 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