summaryrefslogtreecommitdiff
path: root/test/lib/test/unit
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-27 06:35:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-27 06:35:10 +0000
commit71730b42434e3c2dce7e7f6488bd54fae52cae51 (patch)
treec3b362d13161e23cca96cf0f4fd83b30613285f4 /test/lib/test/unit
parent6b52b88d46e5cda0def68665f185a3ac4335076c (diff)
test/unit/assertions.rb: all_assertions
* test/lib/test/unit/assertions.rb (all_assertions): try all assertions and check if all passed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib/test/unit')
-rw-r--r--test/lib/test/unit/assertions.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 727c54c9d5..6c36c4e8c5 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -442,6 +442,28 @@ EOT
assert(failed.empty?, message(m) {failed.pretty_inspect})
end
+ class AllFailures
+ attr_reader :failures
+
+ def initialize
+ @failures = {}
+ end
+
+ def for(key)
+ yield
+ rescue Exception => e
+ @failures[key] = e
+ end
+ end
+
+ def all_assertions(msg = nil)
+ all = AllFailures.new
+ yield all
+ ensure
+ failures = all.failures
+ assert(failures.empty?, message(msg) {mu_pp(failures)})
+ end
+
def build_message(head, template=nil, *arguments) #:nodoc:
template &&= template.chomp
template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) }