зеркало из https://github.com/github/ruby.git
* 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:
Родитель
23ba7541e5
Коммит
51f2207fc9
|
@ -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"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче