ruby-changes:22519
From: naruse <ko1@a...>
Date: Mon, 13 Feb 2012 09:10:32 +0900 (JST)
Subject: [ruby-changes:22519] naruse:r34566 (ruby_1_9_3): merge revision(s) 32527,32567: [Backport #6004]
naruse 2012-02-12 09:42:37 +0900 (Sun, 12 Feb 2012) New Revision: 34566 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34566 Log: merge revision(s) 32527,32567: [Backport #6004] * vm_method.c (rb_add_method): should not call method_added hook for undef operation. [Bug #5015] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_module.rb branches/ruby_1_9_3/version.h branches/ruby_1_9_3/vm_method.c Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34565) +++ ruby_1_9_3/ChangeLog (revision 34566) @@ -1,3 +1,8 @@ +Sun Feb 12 09:38:46 2012 Yukihiro Matsumoto <matz@r...> + + * vm_method.c (rb_add_method): should not call method_added hook + for undef operation. [Bug #5015] + Sun Feb 12 09:29:28 2012 Nobuyoshi Nakada <nobu@r...> * regint.h (PLATFORM_UNALIGNED_WORD_ACCESS): Power PC does not Index: ruby_1_9_3/vm_method.c =================================================================== --- ruby_1_9_3/vm_method.c (revision 34565) +++ ruby_1_9_3/vm_method.c (revision 34566) @@ -318,7 +318,9 @@ default: rb_bug("rb_add_method: unsupported method type (%d)\n", type); } - method_added(klass, mid); + if (type != VM_METHOD_TYPE_UNDEF) { + method_added(klass, mid); + } return me; } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34565) +++ ruby_1_9_3/version.h (revision 34566) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 96 +#define RUBY_PATCHLEVEL 97 #define RUBY_RELEASE_DATE "2012-02-12" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_module.rb =================================================================== --- ruby_1_9_3/test/ruby/test_module.rb (revision 34565) +++ ruby_1_9_3/test/ruby/test_module.rb (revision 34566) @@ -894,6 +894,64 @@ assert_equal mod.instance_method(:a=), memo.shift end + def test_method_undefined + added = [] + undefed = [] + removed = [] + mod = Module.new do + mod = self + def f + end + (class << self ; self ; end).class_eval do + define_method :method_added do |sym| + added << sym + end + define_method :method_undefined do |sym| + undefed << sym + end + define_method :method_removed do |sym| + removed << sym + end + end + end + assert_method_defined?(mod, :f) + mod.module_eval do + undef :f + end + assert_equal [], added + assert_equal [:f], undefed + assert_equal [], removed + end + + def test_method_removed + added = [] + undefed = [] + removed = [] + mod = Module.new do + mod = self + def f + end + (class << self ; self ; end).class_eval do + define_method :method_added do |sym| + added << sym + end + define_method :method_undefined do |sym| + undefed << sym + end + define_method :method_removed do |sym| + removed << sym + end + end + end + assert_method_defined?(mod, :f) + mod.module_eval do + remove_method :f + end + assert_equal [], added + assert_equal [], undefed + assert_equal [:f], removed + end + def test_method_redefinition feature2155 = '[ruby-dev:39400]' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/