mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/unit.rb (assert_nothing_thrown): implemented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c2fab59341
commit
6fa352271f
2 changed files with 17 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Oct 18 13:40:27 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/test/unit.rb (assert_nothing_thrown): implemented.
|
||||||
|
|
||||||
Sat Oct 18 01:33:22 2008 WATANABE Hirofumi <eban@ruby-lang.org>
|
Sat Oct 18 01:33:22 2008 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk: use added options for generic_erb.rb.
|
* common.mk: use added options for generic_erb.rb.
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Test
|
||||||
begin
|
begin
|
||||||
require f
|
require f
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
puts $!
|
puts "#{f}: #{$!}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ module Test
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
if ((args.empty? && !e.instance_of?(MiniTest::Assertion)) ||
|
if ((args.empty? && !e.instance_of?(MiniTest::Assertion)) ||
|
||||||
args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
|
args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
|
||||||
msg = message(msg) { "Exception raised:\n<#{mu_pp(act)}>" }
|
msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
|
||||||
assert(false, msg)
|
assert(false, msg)
|
||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
|
@ -88,6 +88,17 @@ module Test
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_nothing_thrown(msg=nil)
|
||||||
|
begin
|
||||||
|
yield
|
||||||
|
rescue ArgumentError => error
|
||||||
|
raise error if /^uncaught throw (.+)$/ !~ error.message
|
||||||
|
msg = message(msg) { "<#{$1.intern}> was thrown when nothing was expected" }
|
||||||
|
flunk(msg)
|
||||||
|
end
|
||||||
|
assert(true, "Expected nothing to be thrown")
|
||||||
|
end
|
||||||
|
|
||||||
def assert_equal(exp, act, msg = nil)
|
def assert_equal(exp, act, msg = nil)
|
||||||
msg = message(msg) {
|
msg = message(msg) {
|
||||||
exp_str = mu_pp(exp)
|
exp_str = mu_pp(exp)
|
||||||
|
|
Loading…
Reference in a new issue