ruby-changes:41137
From: nobu <ko1@a...>
Date: Sun, 20 Dec 2015 10:43:52 +0900 (JST)
Subject: [ruby-changes:41137] nobu:r53210 (trunk): assertions.rb: show failed indexes
nobu 2015-12-20 10:43:45 +0900 (Sun, 20 Dec 2015) New Revision: 53210 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53210 Log: assertions.rb: show failed indexes * test/lib/test/unit/assertions.rb (AllFailures): show indexes in total number of failure assertions. Modified files: trunk/test/lib/test/unit/assertions.rb Index: test/lib/test/unit/assertions.rb =================================================================== --- test/lib/test/unit/assertions.rb (revision 53209) +++ test/lib/test/unit/assertions.rb (revision 53210) @@ -785,19 +785,23 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L785 attr_reader :failures def initialize + @count = 0 @failures = {} end def for(key) + @count += 1 yield rescue Exception => e - @failures[key] = e + @failures[key] = [@count, e] end def message i = 0 - @failures.map {|k, v| - "\n#{i+=1}. Assertion for #{k.inspect}\n#{v.message.gsub(/^/, ' | ')}" + total = @count.to_s + fmt = "%#{total.size}d" + @failures.map {|k, (n, v)| + "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.message.gsub(/^/, ' | ')}" }.join("\n") end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/