[前][次][番号順一覧][スレッド一覧]

ruby-changes:32533

From: nobu <ko1@a...>
Date: Wed, 15 Jan 2014 17:17:04 +0900 (JST)
Subject: [ruby-changes:32533] nobu:r44613 (trunk): numeric.c: preserve encoding

nobu	2014-01-15 17:16:42 +0900 (Wed, 15 Jan 2014)

  New Revision: 44613

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44613

  Log:
    numeric.c: preserve encoding
    
    * numeric.c (num_init_copy): preserve encoding of error message.

  Modified files:
    trunk/numeric.c
    trunk/test/ruby/test_numeric.rb
Index: numeric.c
===================================================================
--- numeric.c	(revision 44612)
+++ numeric.c	(revision 44613)
@@ -332,7 +332,7 @@ num_sadded(VALUE x, VALUE name) https://github.com/ruby/ruby/blob/trunk/numeric.c#L332
 static VALUE
 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;
 }
Index: test/ruby/test_numeric.rb
===================================================================
--- test/ruby/test_numeric.rb	(revision 44612)
+++ test/ruby/test_numeric.rb	(revision 44613)
@@ -56,11 +56,20 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_numeric.rb#L56
     end
   end
 
-  def test_numeric
+  def test_singleton_method
     a = Numeric.new
     assert_raise_with_message(TypeError, /foo/) { def a.foo; end }
     assert_raise_with_message(TypeError, /\u3042/) { eval("def a.\u3042; end") }
+  end
+
+  def test_dup
+    a = Numeric.new
     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
 
   def test_quo

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]