mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
numeric.c: preserve encoding
* numeric.c (num_init_copy): preserve encoding of error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c1b4b10a12
commit
eb6575e137
2 changed files with 11 additions and 2 deletions
|
@ -332,7 +332,7 @@ num_sadded(VALUE x, VALUE name)
|
||||||
static VALUE
|
static VALUE
|
||||||
num_init_copy(VALUE x, VALUE y)
|
num_init_copy(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
rb_raise(rb_eTypeError, "can't copy %s", rb_obj_classname(x));
|
rb_raise(rb_eTypeError, "can't copy %"PRIsVALUE, rb_obj_class(x));
|
||||||
|
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,20 @@ class TestNumeric < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_numeric
|
def test_singleton_method
|
||||||
a = Numeric.new
|
a = Numeric.new
|
||||||
assert_raise_with_message(TypeError, /foo/) { def a.foo; end }
|
assert_raise_with_message(TypeError, /foo/) { def a.foo; end }
|
||||||
assert_raise_with_message(TypeError, /\u3042/) { eval("def a.\u3042; end") }
|
assert_raise_with_message(TypeError, /\u3042/) { eval("def a.\u3042; end") }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_dup
|
||||||
|
a = Numeric.new
|
||||||
assert_raise(TypeError) { a.dup }
|
assert_raise(TypeError) { a.dup }
|
||||||
|
|
||||||
|
c = Module.new do
|
||||||
|
break eval("class C\u{3042} < Numeric; self; end")
|
||||||
|
end
|
||||||
|
assert_raise_with_message(TypeError, /C\u3042/) {c.new.dup}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_quo
|
def test_quo
|
||||||
|
|
Loading…
Add table
Reference in a new issue