зеркало из https://github.com/github/ruby.git
symbol.c: more informative error message
* symbol.c (sym_check_asciionly): more informative error message with the encoding name and the inspected content. [ruby-core:73398] [Feature #12016] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
390f087d87
Коммит
dfca38eaa2
|
@ -1,3 +1,9 @@
|
|||
Mon Jan 25 15:55:30 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* symbol.c (sym_check_asciionly): more informative error message
|
||||
with the encoding name and the inspected content.
|
||||
[ruby-core:73398] [Feature #12016]
|
||||
|
||||
Mon Jan 25 09:38:26 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_string.rb: added testcase for next!, succ and succ!
|
||||
|
|
3
symbol.c
3
symbol.c
|
@ -430,7 +430,8 @@ sym_check_asciionly(VALUE str)
|
|||
if (!rb_enc_asciicompat(rb_enc_get(str))) return FALSE;
|
||||
switch (rb_enc_str_coderange(str)) {
|
||||
case ENC_CODERANGE_BROKEN:
|
||||
rb_raise(rb_eEncodingError, "invalid encoding symbol");
|
||||
rb_raise(rb_eEncodingError, "invalid symbol in encoding %s :%+"PRIsVALUE,
|
||||
rb_enc_name(rb_enc_get(str)), str);
|
||||
case ENC_CODERANGE_7BIT:
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ class TestSymbol < Test::Unit::TestCase
|
|||
assert_equal(Encoding::US_ASCII, "$-A".force_encoding("iso-8859-15").intern.encoding)
|
||||
assert_equal(Encoding::US_ASCII, "foobar~!".force_encoding("iso-8859-15").intern.encoding)
|
||||
assert_equal(Encoding::UTF_8, "\u{2192}".intern.encoding)
|
||||
assert_raise(EncodingError) {"\xb0a".force_encoding("utf-8").intern}
|
||||
assert_raise_with_message(EncodingError, /\\xb0/i) {"\xb0a".force_encoding("utf-8").intern}
|
||||
end
|
||||
|
||||
def test_singleton_method
|
||||
|
|
Загрузка…
Ссылка в новой задаче