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
This commit is contained in:
nobu 2013-08-13 12:52:25 +00:00
Родитель 5611362cb1
Коммит 944c620dfa
3 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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]'