From def4370a5587ca9ff2e59deaa99599dfd789e9a1 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 11 Nov 2015 00:03:15 +0000 Subject: sprintf.c: hash default value * sprintf.c (rb_str_format): respect default value of a hash. no longer raises KeyError unless the default value of the hash is nil. [ruby-core:71354] [Bug #11661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_sprintf.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 15c809c695..97eb4809c4 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -409,4 +409,10 @@ class TestSprintf < Test::Unit::TestCase assert_equal(enc, e.message.encoding) end end + + def test_named_default + h = Hash.new('world') + assert_equal("hello world", "hello %{location}" % h) + assert_equal("hello world", "hello %s" % h) + end end -- cgit v1.2.3