From: David Flanagan Date: 2009-01-15T03:56:09+09:00 Subject: [ruby-core:21350] Re: Current status of 1.9.1 RC2 This is a multi-part message in MIME format. --------------030003000708010700080608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Yugui (Yuki Sonoda) wrote: > == #984 Test::Unit::Assertions#assert_match double counts number of > assertions > I'm working on this issue. > Yugui, This is the only one of the 23 bugs that wasn't assigned in redmine that I felt qualified to look at. You said you were working on it, but I took a look anyway. My proposed patch is attached. It should go through Ryan, of course, since it is to lib/minitest/unit.rb [Justification: I claim that subtracting one in assert_match, assert_empty and assert_include (and the corresponding refute) methods is the right thing to do. If it is intentional that these implicit assert_respond_to assertions are being counted, then I think that assert_instance_of and assert_kind_of should have similar behavior.] David Flanagan --------------030003000708010700080608 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" Index: unit.rb =================================================================== --- unit.rb (revision 21512) +++ unit.rb (working copy) @@ -76,6 +76,7 @@ def assert_empty obj, msg = nil msg = message(msg) { "Expected #{obj.inspect} to be empty" } assert_respond_to obj, :empty? + self._assertions -= 1 assert obj.empty?, msg end @@ -97,6 +98,7 @@ def assert_includes collection, obj, msg = nil msg = message(msg) { "Expected #{mu_pp(collection)} to include #{mu_pp(obj)}" } assert_respond_to collection, :include? + self._assertions -= 1 assert collection.include?(obj), msg end @@ -118,6 +120,7 @@ def assert_match exp, act, msg = nil msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" } assert_respond_to act, :"=~" + self._assertions -= 1 exp = /#{Regexp.escape(exp)}/ if String === exp && String === act assert exp =~ act, msg end @@ -241,6 +244,7 @@ def refute_empty obj, msg = nil msg = message(msg) { "Expected #{obj.inspect} to not be empty" } assert_respond_to obj, :empty? + self._assertions -= 1 refute obj.empty?, msg end @@ -262,6 +266,7 @@ def refute_includes collection, obj, msg = nil msg = message(msg) { "Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}" } assert_respond_to collection, :include? + self._assertions -= 1 refute collection.include?(obj), msg end @@ -282,6 +287,7 @@ def refute_match exp, act, msg = nil msg = message(msg) { "Expected #{mu_pp(exp)} to not match #{mu_pp(act)}" } assert_respond_to act, :"=~" + self._assertions -= 1 exp = /#{Regexp.escape(exp)}/ if String === exp && String === act refute exp =~ act, msg end --------------030003000708010700080608--