summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-11 09:30:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-11 09:30:31 +0000
commit56e3b493043f5d1b25a52d073f25b8c0f825052f (patch)
treefa88b2cc3b0305c9a4808925566af5416e610482 /test
parent9cf11364817c58b0a8801e458ee2ee1d0d040789 (diff)
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.rb5
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