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

ruby-changes:36391

From: nobu <ko1@a...>
Date: Tue, 18 Nov 2014 03:23:19 +0900 (JST)
Subject: [ruby-changes:36391] nobu:r48472 (trunk): object.c: fix error message

nobu	2014-11-18 03:23:09 +0900 (Tue, 18 Nov 2014)

  New Revision: 48472

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

  Log:
    object.c: fix error message
    
    * object.c (check_setter_id): show the original argument instead
      of nil on TypeError.

  Modified files:
    trunk/ChangeLog
    trunk/object.c
    trunk/test/ruby/test_module.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48471)
+++ ChangeLog	(revision 48472)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 18 03:23:06 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* object.c (check_setter_id): show the original argument instead
+	  of nil on TypeError.
+
 Tue Nov 18 03:20:19 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* symbol.h (is_{local,global,instance,attrset,const,class,junk}_sym):
Index: object.c
===================================================================
--- object.c	(revision 48471)
+++ object.c	(revision 48472)
@@ -1930,8 +1930,8 @@ check_setter_id(VALUE name, int (*valid_ https://github.com/ruby/ruby/blob/trunk/object.c#L1930
     else {
 	VALUE str = rb_check_string_type(name);
 	if (NIL_P(str)) {
-	    rb_raise(rb_eTypeError, "%+"PRIsVALUE" is not a symbol or string",
-		     str);
+	    rb_raise(rb_eTypeError, "% "PRIsVALUE" is not a symbol or string",
+		     name);
 	}
 	if (!valid_name_p(str)) {
 	    rb_name_error_str(str, message, QUOTE(str));
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 48471)
+++ test/ruby/test_module.rb	(revision 48472)
@@ -677,14 +677,16 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L677
 
   def test_const_set_invalid_name
     c1 = Class.new
-    assert_raise(NameError) { c1.const_set(:foo, :foo) }
-    assert_raise(NameError) { c1.const_set("bar", :foo) }
-    assert_raise(TypeError) { c1.const_set(1, :foo) }
+    assert_raise_with_message(NameError, /foo/) { c1.const_set(:foo, :foo) }
+    assert_raise_with_message(NameError, /bar/) { c1.const_set("bar", :foo) }
+    assert_raise_with_message(TypeError, /1/) { c1.const_set(1, :foo) }
     assert_nothing_raised(NameError) { c1.const_set("X\u{3042}", :foo) }
     assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-16be"), :foo) }
     assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-16le"), :foo) }
     assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32be"), :foo) }
     assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32le"), :foo) }
+    cx = EnvUtil.labeled_class("X\u{3042}")
+    assert_raise_with_message(TypeError, /X\u{3042}/) { c1.const_set(cx, :foo) }
   end
 
   def test_const_get_invalid_name

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

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