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

ruby-changes:30328

From: charliesome <ko1@a...>
Date: Mon, 5 Aug 2013 10:02:35 +0900 (JST)
Subject: [ruby-changes:30328] charliesome:r42380 (trunk): * object.c (rb_class_inherited_p): allow iclasses to be tested for

charliesome	2013-08-05 10:02:22 +0900 (Mon, 05 Aug 2013)

  New Revision: 42380

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

  Log:
    * object.c (rb_class_inherited_p): allow iclasses to be tested for
      inheritance. [Bug #8686] [ruby-core:56174]
    
    * test/ruby/test_method.rb: add test

  Modified files:
    trunk/ChangeLog
    trunk/object.c
    trunk/test/ruby/test_method.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42379)
+++ ChangeLog	(revision 42380)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Aug  5 10:01:00 2013  Charlie Somerville  <charliesome@r...>
+
+	* object.c (rb_class_inherited_p): allow iclasses to be tested for
+	  inheritance. [Bug #8686] [ruby-core:56174]
+
+	* test/ruby/test_method.rb: add test
+
 Mon Aug  5 06:13:48 2013  Zachary Scott  <e@z...>
 
 	* enumerator.c: [DOC] Remove reference to Enumerator::Lazy#cycle
Index: object.c
===================================================================
--- object.c	(revision 42379)
+++ object.c	(revision 42380)
@@ -1519,7 +1519,7 @@ rb_class_inherited_p(VALUE mod, VALUE ar https://github.com/ruby/ruby/blob/trunk/object.c#L1519
     VALUE start = mod;
 
     if (mod == arg) return Qtrue;
-    if (!CLASS_OR_MODULE_P(arg)) {
+    if (!CLASS_OR_MODULE_P(arg) && !RB_TYPE_P(arg, T_ICLASS)) {
 	rb_raise(rb_eTypeError, "compared with non class/module");
     }
     arg = RCLASS_ORIGIN(arg);
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 42379)
+++ test/ruby/test_method.rb	(revision 42380)
@@ -262,6 +262,22 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L262
     end
   end
 
+  def test_define_singleton_method_with_extended_method
+    bug8686 = "[ruby-core:56174]"
+
+    m = Module.new do
+      extend self
+
+      def a
+        "a"
+      end
+    end
+
+    assert_nothing_raised do
+      m.define_singleton_method(:a, m.method(:a))
+    end
+  end
+
   def test_define_method_transplating
     feature4254 = '[ruby-core:34267]'
     m = Module.new {define_method(:meth, M.instance_method(:meth))}

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

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