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
This commit is contained in:
nobu 2015-11-11 00:03:15 +00:00
parent 8d9e360007
commit def4370a55
3 changed files with 17 additions and 5 deletions

View file

@ -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 %<location>s" % h)
end
end