diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 07:11:04 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-22 07:11:04 +0000 |
commit | e102f56340d50a2459312df876eb3010cc4b92ef (patch) | |
tree | 1c0bf7ed7a339acebc3a79fb19ac7e79b9a12cc5 /test/lib | |
parent | 88efadca4aea13b6c5f3cd4b39c932004d4a23e2 (diff) |
merge revision(s) 54131: [Backport #8851]
* defs/keywords (alias, undef): symbol literals are allowed.
* parse.y (parse_percent): should parse symbol literals for alias
and undef. [ruby-dev:47681] [Bug #8851]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@54686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/test/unit/assertions.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb index 727c54c9d5..27a45f3879 100644 --- a/test/lib/test/unit/assertions.rb +++ b/test/lib/test/unit/assertions.rb @@ -442,6 +442,42 @@ EOT assert(failed.empty?, message(m) {failed.pretty_inspect}) end + class AllFailures + attr_reader :failures + + def initialize + @count = 0 + @failures = {} + end + + def for(key) + @count += 1 + yield + rescue Exception => e + @failures[key] = [@count, e] + end + + def message + i = 0 + 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.b.gsub(/^/, ' | ')}" + }.join("\n") + end + + def pass? + @failures.empty? + end + end + + def all_assertions(msg = nil) + all = AllFailures.new + yield all + ensure + assert(all.pass?, message(msg) {all.message.chomp(".")}) + end + def build_message(head, template=nil, *arguments) #:nodoc: template &&= template.chomp template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) } |