ruby-changes:46754
From: nobu <ko1@a...>
Date: Wed, 24 May 2017 16:57:22 +0900 (JST)
Subject: [ruby-changes:46754] nobu:r58869 (trunk): assertions.rb: AllFailures#foreach
nobu 2017-05-24 16:57:18 +0900 (Wed, 24 May 2017) New Revision: 58869 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58869 Log: assertions.rb: AllFailures#foreach * test/lib/test/unit/assertions.rb (AllFailures#foreach): shortcircuit for `each` and `AllFailures#for`. Modified files: trunk/test/lib/test/unit/assertions.rb Index: test/lib/test/unit/assertions.rb =================================================================== --- test/lib/test/unit/assertions.rb (revision 58868) +++ test/lib/test/unit/assertions.rb (revision 58869) @@ -835,6 +835,17 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L835 @failures[key] = [@count, e] end + def foreach(*keys) + keys.each do |key| + @count += 1 + begin + yield key + rescue Exception => e + @failures[key] = [@count, e] + end + end + end + def message i = 0 total = @count.to_s @@ -857,6 +868,14 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L868 end alias all_assertions assert_all_assertions + def assert_all_assertions_foreach(msg = nil, *keys, &block) + all = AllFailures.new + all.foreach(*keys, &block) + ensure + assert(all.pass?, message(msg) {all.message.chomp(".")}) + end + alias all_assertions_foreach assert_all_assertions_foreach + def build_message(head, template=nil, *arguments) #:nodoc: template &&= template.chomp template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/