mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
23ba7541e5
commit
51f2207fc9
1 changed files with 8 additions and 1 deletions
|
@ -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("%<key>s", :key => "value"))
|
||||
e = assert_raise(ArgumentError) {sprintf("%1$<key2>s", :key => "value")}
|
||||
assert_equal("named<key2> after numbered", e.message)
|
||||
e = assert_raise(ArgumentError) {sprintf("%s%s%<key2>s", "foo", "bar", :key => "value")}
|
||||
assert_equal("named<key2> after unnumbered(2)", e.message)
|
||||
e = assert_raise(ArgumentError) {sprintf("%<key><key2>s", :key => "value")}
|
||||
assert_equal("named<key2> after <key>", 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("%<key>{key2}", :key => "value")}
|
||||
assert_equal("named{key2} after <key>", e.message)
|
||||
assert_equal("value{key2}", sprintf("%{key}{key2}", :key => "value"))
|
||||
|
|
Loading…
Reference in a new issue