From 51f2207fc9be8b356601b5505dfdffef2db5e5dd Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 11 Apr 2012 13:01:14 +0000 Subject: [PATCH] * test/ruby/test_sprintf.rb (test_named_untyped, test_named_typed): split and add assertions for exception when named parameter after unnumbered. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_sprintf.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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"))