summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora_matsuda <a_matsuda@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 12:42:01 +0000
committera_matsuda <a_matsuda@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 12:42:01 +0000
commit26766ee89c31b16be74803c08cb0d2de2d2fc58e (patch)
treedd8d187933c813034cbd0fd051342f7cb5437015
parent1908874bf4e65e6f65323099ff1d979a14a7a33e (diff)
* eval.c (Init_eval): Make Module#include and Module#prepend public
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--eval.c5
-rw-r--r--test/ruby/test_module.rb12
3 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d06cc33275..565d2154d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Sep 3 21:41:37 2013 Akira Matsuda <ronnie@dio.jp>
+
+ * 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@ruby-lang.org>
* thread_pthread.c (sys/dyntune.h): for gettune().
diff --git a/eval.c b/eval.c
index 445524b0c3..2b0838a180 100644
--- a/eval.c
+++ b/eval.c
@@ -1592,11 +1592,12 @@ Init_eval(void)
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");
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 7d5eb99ff0..9b253b3776 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -351,6 +351,12 @@ class TestModule < Test::Unit::TestCase
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
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")