diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 00:03:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 00:03:15 +0000 |
commit | c5487f08b75ce31ce8673a56d6a12c5e0076befb (patch) | |
tree | 4ca44c50485fddc5c357d97b3858e6c0c3f2bb7b /test | |
parent | 8f90345421247b7c863a06c09db7f550cf838045 (diff) | |
download | ruby-c5487f08b75ce31ce8673a56d6a12c5e0076befb.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')
-rw-r--r-- | test/ruby/test_sprintf.rb | 6 |
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 |