mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compar.c: preserve encodings
* compar.c (rb_cmperr): preserve encodings of arguments in the message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f9b7a2a33f
commit
40db3d97ac
3 changed files with 14 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Aug 19 13:59:43 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compar.c (rb_cmperr): preserve encodings of arguments in the
|
||||
message.
|
||||
|
||||
Tue Aug 19 10:13:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/thread/thread.c (get_array): check instance variables are
|
||||
|
|
11
compar.c
11
compar.c
|
@ -18,17 +18,16 @@ static ID cmp;
|
|||
void
|
||||
rb_cmperr(VALUE x, VALUE y)
|
||||
{
|
||||
const char *classname;
|
||||
VALUE classname;
|
||||
|
||||
if (SPECIAL_CONST_P(y)) {
|
||||
y = rb_inspect(y);
|
||||
classname = StringValuePtr(y);
|
||||
classname = rb_inspect(y);
|
||||
}
|
||||
else {
|
||||
classname = rb_obj_classname(y);
|
||||
classname = rb_class_path(rb_obj_class(y));
|
||||
}
|
||||
rb_raise(rb_eArgError, "comparison of %s with %s failed",
|
||||
rb_obj_classname(x), classname);
|
||||
rb_raise(rb_eArgError, "comparison of %"PRIsVALUE" with %"PRIsVALUE" failed",
|
||||
rb_class_path(rb_obj_class(x)), classname);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -73,6 +73,10 @@ class TestComparable < Test::Unit::TestCase
|
|||
def test_err
|
||||
assert_raise(ArgumentError) { 1.0 < nil }
|
||||
assert_raise(ArgumentError) { 1.0 < Object.new }
|
||||
e = Module.new {break module_eval("class E\u{30a8 30e9 30fc}; self; end")}
|
||||
assert_raise_with_message(ArgumentError, /E\u{30a8 30e9 30fc}/) {
|
||||
1.0 < e.new
|
||||
}
|
||||
end
|
||||
|
||||
def test_inversed_compare
|
||||
|
|
Loading…
Reference in a new issue