mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 19:44:01 +02:00
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:
parent
8d9e360007
commit
def4370a55
3 changed files with 17 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue