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

ruby-changes:35486

From: nobu <ko1@a...>
Date: Sat, 13 Sep 2014 10:22:10 +0900 (JST)
Subject: [ruby-changes:35486] nobu:r47568 (trunk): eval.c: fix message as same as previous versions

nobu	2014-09-13 10:22:01 +0900 (Sat, 13 Sep 2014)

  New Revision: 47568

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

  Log:
    eval.c: fix message as same as previous versions
    
    * eval.c (rb_frozen_class_p): fix message for singleton class of
      class/module as same as previous versions.

  Modified files:
    trunk/eval.c
    trunk/test/ruby/test_class.rb
Index: eval.c
===================================================================
--- eval.c	(revision 47567)
+++ eval.c	(revision 47568)
@@ -412,8 +412,21 @@ rb_frozen_class_p(VALUE klass) https://github.com/ruby/ruby/blob/trunk/eval.c#L412
     if (OBJ_FROZEN(klass)) {
 	const char *desc;
 
-	if (FL_TEST(klass, FL_SINGLETON))
+	if (FL_TEST(klass, FL_SINGLETON)) {
 	    desc = "object";
+	    klass = rb_ivar_get(klass, id__attached__);
+	    if (!SPECIAL_CONST_P(klass)) {
+		switch (BUILTIN_TYPE(klass)) {
+		  case T_MODULE:
+		  case T_ICLASS:
+		    desc = "Module";
+		    break;
+		  case T_CLASS:
+		    desc = "Class";
+		    break;
+		}
+	    }
+	}
 	else {
 	    switch (BUILTIN_TYPE(klass)) {
 	      case T_MODULE:
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 47567)
+++ test/ruby/test_class.rb	(revision 47568)
@@ -389,8 +389,12 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L389
     obj = Object.new
     c = obj.singleton_class
     obj.freeze
-    assert_raise(RuntimeError, /frozen object/) {
+    assert_raise_with_message(RuntimeError, /frozen object/) {
       c.class_eval {def f; end}
     }
+    c = Class.new.freeze
+    assert_raise_with_message(RuntimeError, /frozen Class/) {
+      def c.f; end
+    }
   end
 end

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

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