From 4b346b0e7159d95ed0afce0840adaf62d7c1381f Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 9 Jan 2016 14:19:38 +0000 Subject: test_hash.rb: add test * test/ruby/test_hash.rb (test_try_convert): Add test for Hash.try_convert. [Fix GH-1190] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_hash.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 6ee029722a..3baba6a0b7 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -148,6 +148,14 @@ class TestHash < Test::Unit::TestCase end + def test_try_convert + assert_equal({1=>2}, Hash.try_convert({1=>2})) + assert_equal(nil, Hash.try_convert("1=>2")) + o = Object.new + def o.to_hash; {3=>4} end + assert_equal({3=>4}, Hash.try_convert(o)) + end + def test_AREF # '[]' t = Time.now h = @cls[ -- cgit v1.2.3