summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-23 03:42:29 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-23 03:42:29 +0000
commit9471f4187f104f7a0942fdccc884e57cf8027d07 (patch)
tree313b0a21a768e3d949de8f3e567bc5fe87bea811 /test/ruby/test_array.rb
parent573762a7b7bbaf08aa1c27d95a9bcb15bac9ee2e (diff)
* array.c: Have to_h raise on elements that are not key-value pairs [#9239]
* enum.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 526fcabb1b..b648c404ed 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1467,12 +1467,18 @@ class TestArray < Test::Unit::TestCase
end
array = [
[:key, :value],
- [:ignore_me],
- [:ignore, :me, :too],
- :ignore_me,
kvp,
]
assert_equal({key: :value, obtained: :via_to_ary}, array.to_h)
+
+ e = assert_raise(TypeError) {
+ [[:first_one, :ok], :not_ok].to_h
+ }
+ assert_equal "wrong element type Symbol at 1 (expected array)", e.message
+ e = assert_raise(ArgumentError) {
+ [[:first_one, :ok], [1, 2], [:not_ok]].to_h
+ }
+ assert_equal "wrong array length at 2 (expected 2, was 1)", e.message
end
def test_uniq