summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-13 12:52:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-13 12:52:25 +0000
commit944c620dfabbf46e7a96b96b5dad527d985492d3 (patch)
tree1ea4735cc2005a1ae0b77dda87f746e4ac8adbaa
parent5611362cb12eaa8c489d3090a40ca0435c430978 (diff)
object.c: undef Module#prepend_features on Class
* object.c (Init_Object): undef Module#prepend_features on Class, as well as Module#append_features. [Fixes GH-376] * test_class.rb: Added test for above. And ensure type checking on similar methods as module_function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--object.c1
-rw-r--r--test/ruby/test_class.rb26
3 files changed, 35 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3510975949..475cc3f9e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Aug 13 21:52:15 2013 Kenichi Kamiya <kachick1@gmail.com>
+
+ * object.c (Init_Object): undef Module#prepend_features on Class, as
+ well as Module#append_features. [Fixes GH-376]
+
+ * test_class.rb: Added test for above. And ensure type checking
+ on similar methods as module_function.
+
Tue Aug 13 08:52:18 2013 Zachary Scott <e@zzak.io>
* doc/syntax/literals.rdoc: [DOC] String literal concat by @cknadler
diff --git a/object.c b/object.c
index 965c83cb84..265601c799 100644
--- a/object.c
+++ b/object.c
@@ -3242,6 +3242,7 @@ Init_Object(void)
rb_define_alloc_func(rb_cClass, rb_class_s_alloc);
rb_undef_method(rb_cClass, "extend_object");
rb_undef_method(rb_cClass, "append_features");
+ rb_undef_method(rb_cClass, "prepend_features");
/*
* Document-class: Data
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 47848f3184..b40cab8050 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -105,6 +105,32 @@ class TestClass < Test::Unit::TestCase
end
end
+ def test_extend_object
+ c = Class.new
+ assert_raise(TypeError) do
+ Module.instance_method(:extend_object).bind(c).call(Object.new)
+ end
+ end
+
+ def test_append_features
+ c = Class.new
+ assert_raise(TypeError) do
+ Module.instance_method(:append_features).bind(c).call(Module.new)
+ end
+ end
+
+ def test_prepend_features
+ c = Class.new
+ assert_raise(TypeError) do
+ Module.instance_method(:prepend_features).bind(c).call(Module.new)
+ end
+ end
+
+ def test_module_specific_methods
+ assert_empty(Class.private_instance_methods(true) &
+ [:module_function, :extend_object, :append_features, :prepend_features])
+ end
+
def test_method_redefinition
feature2155 = '[ruby-dev:39400]'