Hi,

Since yesterday, Proc created from the block passed with
ampersand got to be same as the original Proc.  So I guess
Test::Unit::Util::ProcWrapper is no longer needed, with this
patch.


Index: lib/test/unit/util/observable.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/util/observable.rb,v retrieving revision 1.1.1.2 diff -u -2 -p -d -r1.1.1.2 observable.rb --- lib/test/unit/util/observable.rb 12 Feb 2003 04:22:35 -0000 1.1.1.2 +++ lib/test/unit/util/observable.rb 14 Dec 2003 07:50:53 -0000 @@ -5,6 +5,4 @@ # License:: Ruby license. -require 'test/unit/util/procwrapper' - module Test module Unit @@ -15,7 +13,4 @@ module Test # events. module Observable - # We use this for defaults since nil might mean something - NOTHING = "NOTHING/#{__id__}" - # Adds the passed proc as a listener on the # channel indicated by channel_name. listener_key @@ -29,15 +24,19 @@ module Test # listener = add_listener("Channel") { ... } # remove_listener("Channel", listener) - def add_listener(channel_name, listener_key=NOTHING, &listener) # :yields: value - unless(block_given?) + def add_listener(channel_name, *rest, &listener) # :yields: value + unless block_given? raise ArgumentError.new("No callback was passed as a listener") end - - key = listener_key - if (listener_key == NOTHING) + + case rest.size + when 1 + key = listener_key = rest.first + when 0 listener_key = listener - key = ProcWrapper.new(listener) + key = listener + else + raise ArgumentError, "wrong number of arguments(#{rest.size+1} for 2)" end - + channels[channel_name] ||= {} channels[channel_name][key] = listener @@ -51,13 +50,6 @@ module Test def remove_listener(channel_name, listener_key) channel = channels[channel_name] - return nil unless (channel) - key = listener_key - if (listener_key.instance_of?(Proc)) - key = ProcWrapper.new(listener_key) - end - if (channel.has_key?(key)) - return channel.delete(key) - end - return nil + return nil unless channel + channel.delete(listener_key) end
-- Nobu Nakada