diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 09:30:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 09:30:31 +0000 |
commit | 4d57720d1a8f8bdc492e6988bb01a716c814cbbd (patch) | |
tree | fa88b2cc3b0305c9a4808925566af5416e610482 /test | |
parent | 19294fbb8d2cb8ce23d45a0af927c9d5df65f60d (diff) | |
download | ruby-4d57720d1a8f8bdc492e6988bb01a716c814cbbd.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_sprintf.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 97eb4809c4..8af94a89fe 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -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 |