ruby-changes:30462
From: nobu <ko1@a...>
Date: Tue, 13 Aug 2013 21:52:31 +0900 (JST)
Subject: [ruby-changes:30462] nobu:r42541 (trunk): object.c: undef Module#prepend_features on Class
nobu 2013-08-13 21:52:25 +0900 (Tue, 13 Aug 2013) New Revision: 42541 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42541 Log: 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. Modified files: trunk/ChangeLog trunk/object.c trunk/test/ruby/test_class.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42540) +++ ChangeLog (revision 42541) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Aug 13 21:52:15 2013 Kenichi Kamiya <kachick1@g...> + + * 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@z...> * doc/syntax/literals.rdoc: [DOC] String literal concat by @cknadler Index: object.c =================================================================== --- object.c (revision 42540) +++ object.c (revision 42541) @@ -3242,6 +3242,7 @@ Init_Object(void) https://github.com/ruby/ruby/blob/trunk/object.c#L3242 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 Index: test/ruby/test_class.rb =================================================================== --- test/ruby/test_class.rb (revision 42540) +++ test/ruby/test_class.rb (revision 42541) @@ -105,6 +105,32 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L105 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]' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/