mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 19:44:01 +02:00
sprintf.c: nil value is valid
* sprintf.c (rb_str_format): look up the key, then get default value and raise KeyError if the returned value is nil. [ruby-dev:49338] [Ruby trunk - Bug #11677] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9cf1136481
commit
56e3b49304
5 changed files with 30 additions and 10 deletions
|
@ -415,4 +415,9 @@ class TestSprintf < Test::Unit::TestCase
|
|||
assert_equal("hello world", "hello %{location}" % h)
|
||||
assert_equal("hello world", "hello %<location>s" % h)
|
||||
end
|
||||
|
||||
def test_named_with_nil
|
||||
h = { key: nil, key2: "key2_val" }
|
||||
assert_equal("key is , key2 is key2_val", "key is %{key}, key2 is %{key2}" % h)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue