[前][次][番号順一覧][スレッド一覧]

ruby-changes:33674

From: usa <ko1@a...>
Date: Wed, 30 Apr 2014 16:45:57 +0900 (JST)
Subject: [ruby-changes:33674] usa:r45755 (ruby_2_0_0): revert r45747 because it introduced severe incompatibility.

usa	2014-04-30 16:45:49 +0900 (Wed, 30 Apr 2014)

  New Revision: 45755

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45755

  Log:
    revert r45747 because it introduced severe incompatibility.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/lib/delegate.rb
    branches/ruby_2_0_0/test/ruby/envutil.rb
    branches/ruby_2_0_0/test/test_delegate.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45754)
+++ ruby_2_0_0/ChangeLog	(revision 45755)
@@ -34,27 +34,6 @@ Wed Apr 30 16:09:18 2014  Nobuyoshi Naka https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L34
 	* vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an
 	  inline function.
 
-Wed Apr 30 15:20:44 2014  Nobuyoshi Nakada  <nobu@r...>
-
-	* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
-
-	* lib/delegate.rb (DelegateClass#__getobj__): ditto.
-
-Wed Apr 30 15:20:44 2014  Nobuyoshi Nakada  <nobu@r...>
-
-	* lib/delegate.rb (Delegator#method_missing): try private methods defined in
-	  Kernel after the target.  [Fixes GH-449]
-
-Wed Apr 30 15:20:44 2014  Nobuyoshi Nakada  <nobu@r...>
-
-	* lib/delegate.rb (Delegator#send): separate from method_missing so
-	  that super calls proper method.
-
-Wed Apr 30 15:20:44 2014  Nobuyoshi Nakada  <nobu@r...>
-
-	* lib/delegate.rb (Delegator#send): override to get rid of global function interference.
-	  [Fixes GH-449]
-
 Wed Apr 30 15:04:25 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/readline/extconf.rb: fix typo, `$defs` not `$DEFS`.
Index: ruby_2_0_0/lib/delegate.rb
===================================================================
--- ruby_2_0_0/lib/delegate.rb	(revision 45754)
+++ ruby_2_0_0/lib/delegate.rb	(revision 45755)
@@ -43,16 +43,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L43
 class Delegator < BasicObject
   kernel = ::Kernel.dup
   kernel.class_eval do
-    alias __raise__ raise
     [:to_s,:inspect,:=~,:!~,:===,:<=>,:eql?,:hash].each do |m|
       undef_method m
     end
-    private_instance_methods.each do |m|
-      if /\Ablock_given\?\z|iterator\?\z|\A__raise__\z/ =~ m
-        next
-      end
-      undef_method m
-    end
   end
   include kernel
 
@@ -76,15 +69,9 @@ class Delegator < BasicObject https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L69
   def method_missing(m, *args, &block)
     target = self.__getobj__
     begin
-      if target.respond_to?(m)
-        target.__send__(m, *args, &block)
-      elsif ::Kernel.respond_to?(m, true)
-        ::Kernel.instance_method(m).bind(self).(*args, &block)
-      else
-        super(m, *args, &block)
-      end
+      target.respond_to?(m) ? target.__send__(m, *args, &block) : super(m, *args, &block)
     ensure
-      $@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:(?:#{[__LINE__-7, __LINE__-5, __LINE__-3].join('|')}):"o =~ t} if $@
+      $@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
     end
   end
 
@@ -155,7 +142,7 @@ class Delegator < BasicObject https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L142
   # method calls are being delegated to.
   #
   def __getobj__
-    __raise__ ::NotImplementedError, "need to define `__getobj__'"
+    raise NotImplementedError, "need to define `__getobj__'"
   end
 
   #
@@ -163,7 +150,7 @@ class Delegator < BasicObject https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L150
   # to _obj_.
   #
   def __setobj__(obj)
-    __raise__ ::NotImplementedError, "need to define `__setobj__'"
+    raise NotImplementedError, "need to define `__setobj__'"
   end
 
   #
@@ -278,7 +265,6 @@ end https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L265
 class SimpleDelegator<Delegator
   # Returns the current object method calls are being delegated to.
   def __getobj__
-    __raise__ ::ArgumentError, "not delegated" unless defined?(@delegate_sd_obj)
     @delegate_sd_obj
   end
 
@@ -297,7 +283,7 @@ class SimpleDelegator<Delegator https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L283
   #   puts names[1]    # => Sinclair
   #
   def __setobj__(obj)
-    __raise__ ::ArgumentError, "cannot delegate to self" if self.equal?(obj)
+    raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
     @delegate_sd_obj = obj
   end
 end
@@ -353,11 +339,10 @@ def DelegateClass(superclass) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/delegate.rb#L339
   methods -= [:to_s,:inspect,:=~,:!~,:===]
   klass.module_eval do
     def __getobj__  # :nodoc:
-      __raise__ ::ArgumentError, "not delegated" unless defined?(@delegate_dc_obj)
       @delegate_dc_obj
     end
     def __setobj__(obj)  # :nodoc:
-      __raise__ ::ArgumentError, "cannot delegate to self" if self.equal?(obj)
+      raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
       @delegate_dc_obj = obj
     end
     methods.each do |method|
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45754)
+++ ruby_2_0_0/version.h	(revision 45755)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-04-30"
-#define RUBY_PATCHLEVEL 475
+#define RUBY_PATCHLEVEL 476
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 4
Index: ruby_2_0_0/test/ruby/envutil.rb
===================================================================
--- ruby_2_0_0/test/ruby/envutil.rb	(revision 45754)
+++ ruby_2_0_0/test/ruby/envutil.rb	(revision 45755)
@@ -379,29 +379,6 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/envutil.rb#L379
         AssertFile
       end
 
-      def assert_raise_with_message(exception, expected, msg = nil, &block)
-        case expected
-        when String
-          assert = :assert_equal
-        when Regexp
-          assert = :assert_match
-        else
-          raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
-        end
-
-        ex = assert_raise(exception, *msg) {yield}
-        msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"}
-
-        if assert == :assert_equal
-          assert_equal(expected, ex.message, msg)
-        else
-          msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp ex.message}" }
-          assert expected =~ ex.message, msg
-          block.binding.eval("proc{|_|$~=_}").call($~)
-        end
-        ex
-      end
-
       class << (AssertFile = Struct.new(:message).new)
         include Assertions
         def assert_file_predicate(predicate, *args)
Index: ruby_2_0_0/test/test_delegate.rb
===================================================================
--- ruby_2_0_0/test/test_delegate.rb	(revision 45754)
+++ ruby_2_0_0/test/test_delegate.rb	(revision 45755)
@@ -1,6 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/test_delegate.rb#L1
 require 'test/unit'
 require 'delegate'
-require_relative 'ruby/envutil'
 
 class TestDelegateClass < Test::Unit::TestCase
   module M
@@ -134,39 +133,4 @@ class TestDelegateClass < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/test_delegate.rb#L133
     assert_raise(NoMethodError, '[ruby-dev:40314]#4') {d.delegate_test_private}
     assert_raise(NoMethodError, '[ruby-dev:40314]#5') {d.send(:delegate_test_private)}
   end
-
-  def test_global_function
-    klass = Class.new do
-      def open
-      end
-    end
-    obj = klass.new
-    d = SimpleDelegator.new(obj)
-    assert_nothing_raised(ArgumentError) {obj.open}
-    assert_nothing_raised(ArgumentError) {d.open}
-    assert_nothing_raised(ArgumentError) {d.send(:open)}
-  end
-
-  def test_send_method_in_delegator
-    d = Class.new(SimpleDelegator) do
-      def foo
-        "foo"
-      end
-    end.new(Object.new)
-    assert_equal("foo", d.send(:foo))
-  end
-
-  def test_unset_simple_delegator
-    d = SimpleDelegator.allocate
-    assert_raise_with_message(ArgumentError, /not delegated/) {
-      d.__getobj__
-    }
-  end
-
-  def test_unset_delegate_class
-    d = IV.allocate
-    assert_raise_with_message(ArgumentError, /not delegated/) {
-      d.__getobj__
-    }
-  end
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Reverse-merged /trunk:r43682,43727,43752,43759


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]