1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Improve error message

ref [Bug #13761]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2017-07-31 03:35:22 +00:00
parent 84d83482c8
commit d9d2bbe4b9
2 changed files with 3 additions and 3 deletions

View file

@ -521,7 +521,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
for (t = p; t < end && *t != '%'; t++) ; for (t = p; t < end && *t != '%'; t++) ;
if (t + 1 == end) { if (t + 1 == end) {
rb_raise(rb_eArgError, "incomplete format specifier"); rb_raise(rb_eArgError, "incomplete format specifier; use %%%% (double %%) instead");
} }
PUSH(p, t - p); PUSH(p, t - p);
if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) { if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {

View file

@ -425,11 +425,11 @@ class TestSprintf < Test::Unit::TestCase
end end
def test_percent_sign_at_end def test_percent_sign_at_end
assert_raise_with_message(ArgumentError, "incomplete format specifier") do assert_raise_with_message(ArgumentError, "incomplete format specifier; use %% (double %) instead") do
sprintf("%") sprintf("%")
end end
assert_raise_with_message(ArgumentError, "incomplete format specifier") do assert_raise_with_message(ArgumentError, "incomplete format specifier; use %% (double %) instead") do
sprintf("abc%") sprintf("abc%")
end end
end end