summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-27 23:49:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-27 23:49:52 +0000
commit03cf0a81cdc2342a8e0e56b460dd8dc8b373a128 (patch)
tree2d84df58e31cb609f86afefc0c7e661f8d04eec1 /test
parentabeaf6c52206160bb4a5026a57f1a6b6fa8021ec (diff)
downloadruby-03cf0a81cdc2342a8e0e56b460dd8dc8b373a128.tar.gz
ruby-03cf0a81cdc2342a8e0e56b460dd8dc8b373a128.tar.xz
ruby-03cf0a81cdc2342a8e0e56b460dd8dc8b373a128.zip
* sprintf.c (rb_str_format): checks if named argument given twice.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 c2669a713..15424d98a 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -273,4 +273,10 @@ class TestSprintf < Test::Unit::TestCase
b2 = (/\.\./ =~ s2) != nil
assert(b1 == b2, "[ruby-dev:33224]")
end
+
+ def test_named
+ assert_equal("value", sprintf("%<key>s", :key => "value"))
+ assert_raise(ArgumentError) {sprintf("%1$<key2>s", :key => "value")}
+ assert_raise(ArgumentError) {sprintf("%<key><key2>s", :key => "value")}
+ end
end