aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_sprintf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-11 00:03:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-11 00:03:15 +0000
commitdef4370a5587ca9ff2e59deaa99599dfd789e9a1 (patch)
tree4ca44c50485fddc5c357d97b3858e6c0c3f2bb7b /test/ruby/test_sprintf.rb
parent8d9e36000747bb650d169d44dd812bfc7e360bd5 (diff)
downloadruby-def4370a5587ca9ff2e59deaa99599dfd789e9a1.tar.gz
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
Diffstat (limited to 'test/ruby/test_sprintf.rb')
-rw-r--r--test/ruby/test_sprintf.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 15c809c695..97eb4809c4 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -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