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

ruby-changes:30730

From: a_matsuda <ko1@a...>
Date: Tue, 3 Sep 2013 21:42:07 +0900 (JST)
Subject: [ruby-changes:30730] a_matsuda:r42809 (trunk): * eval.c (Init_eval): Make Module#include and Module#prepend public

a_matsuda	2013-09-03 21:42:01 +0900 (Tue, 03 Sep 2013)

  New Revision: 42809

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

  Log:
    * eval.c (Init_eval): Make Module#include and Module#prepend public

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/test/ruby/test_module.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42808)
+++ ChangeLog	(revision 42809)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Sep  3 21:41:37 2013  Akira Matsuda  <ronnie@d...>
+
+	* eval.c (Init_eval): Make Module#include and Module#prepend public
+
+	* test/ruby/test_module.rb (class TestModule): Test for above
+
 Tue Sep  3 21:35:19 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread_pthread.c (sys/dyntune.h): for gettune().
Index: eval.c
===================================================================
--- eval.c	(revision 42808)
+++ eval.c	(revision 42809)
@@ -1592,11 +1592,12 @@ Init_eval(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L1592
     rb_define_global_function("__callee__", rb_f_callee_name, 0);
     rb_define_global_function("__dir__", f_current_dirname, 0);
 
+    rb_define_method(rb_cModule, "include", rb_mod_include, -1);
+    rb_define_method(rb_cModule, "prepend", rb_mod_prepend, -1);
+
     rb_define_private_method(rb_cModule, "append_features", rb_mod_append_features, 1);
     rb_define_private_method(rb_cModule, "extend_object", rb_mod_extend_object, 1);
-    rb_define_private_method(rb_cModule, "include", rb_mod_include, -1);
     rb_define_private_method(rb_cModule, "prepend_features", rb_mod_prepend_features, 1);
-    rb_define_private_method(rb_cModule, "prepend", rb_mod_prepend, -1);
     rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
     rb_define_private_method(rb_cModule, "using", mod_using, 1);
     rb_undef_method(rb_cClass, "refine");
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 42808)
+++ test/ruby/test_module.rb	(revision 42809)
@@ -351,6 +351,12 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L351
     refute_equal original, b.inspect, bug6454
   end
 
+  def test_public_include
+    assert_nothing_raised('#8846') do
+      Module.new.include(Module.new { def foo; end }).instance_methods == [:foo]
+    end
+  end
+
   def test_included_modules
     assert_equal([], Mixin.included_modules)
     assert_equal([Mixin], User.included_modules)
@@ -1380,6 +1386,12 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1386
     assert_equal(expected, obj.m1)
   end
 
+  def test_public_prepend
+    assert_nothing_raised('#8846') do
+      Class.new.prepend(Module.new)
+    end
+  end
+
   def test_prepend_inheritance
     bug6654 = '[ruby-core:45914]'
     a = labeled_module("a")

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

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