aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 20:44:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-20 20:44:49 +0000
commitf262909cba89361e786a7e097908d5923fff61c3 (patch)
treebbb28192f5115f6394ab8e30aa5abaccf4096d28 /test/ruby/test_hash.rb
parent32ee210345c56347476bb2b2a166fafaf1f61e3f (diff)
downloadruby-f262909cba89361e786a7e097908d5923fff61c3.tar.gz
* hash.c (rb_hash_flatten): use NUM2INT to raise TypeError on 32bit
platform. it's introduced by r42039 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 75a3a396af..1baff2982c 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -879,6 +879,15 @@ class TestHash < Test::Unit::TestCase
def test_flatten
assert_equal([[1], [2]], {[1] => [2]}.flatten)
+
+ a = {1=> "one", 2 => [2,"two"], 3 => [3, ["three"]]}
+ assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten)
+ assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(-1))
+ assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(0))
+ assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(1))
+ assert_equal([1, "one", 2, 2, "two", 3, 3, ["three"]], a.flatten(2))
+ assert_equal([1, "one", 2, 2, "two", 3, 3, "three"], a.flatten(3))
+ assert_raise(TypeError){ a.flatten(Object) }
end
def test_callcc