diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 7d125fca43..58884d19b1 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -323,15 +323,22 @@ class TestSprintf < Test::Unit::TestCase assert(b1 == b2, "[ruby-dev:33224]") end - def test_named + def test_named_untyped assert_equal("value", sprintf("%s", :key => "value")) e = assert_raise(ArgumentError) {sprintf("%1$s", :key => "value")} assert_equal("named after numbered", e.message) + e = assert_raise(ArgumentError) {sprintf("%s%s%s", "foo", "bar", :key => "value")} + assert_equal("named after unnumbered(2)", e.message) e = assert_raise(ArgumentError) {sprintf("%s", :key => "value")} assert_equal("named after ", e.message) + end + + def test_named_typed assert_equal("value", sprintf("%{key}", :key => "value")) e = assert_raise(ArgumentError) {sprintf("%1${key2}", :key => "value")} assert_equal("named{key2} after numbered", e.message) + e = assert_raise(ArgumentError) {sprintf("%s%s%{key2}", "foo", "bar", :key => "value")} + assert_equal("named{key2} after unnumbered(2)", e.message) e = assert_raise(ArgumentError) {sprintf("%{key2}", :key => "value")} assert_equal("named{key2} after ", e.message) assert_equal("value{key2}", sprintf("%{key}{key2}", :key => "value"))