From 6fa352271f9bdfe1c86f0d29df4e56bdb2eabcd3 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 18 Oct 2008 04:41:17 +0000 Subject: * 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 --- lib/test/unit.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/test/unit.rb b/lib/test/unit.rb index d81a111631..9c15806963 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -48,7 +48,7 @@ module Test begin require f rescue LoadError - puts $! + puts "#{f}: #{$!}" end } @@ -79,7 +79,7 @@ module Test rescue Exception => e if ((args.empty? && !e.instance_of?(MiniTest::Assertion)) || 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) else raise @@ -88,6 +88,17 @@ module Test nil 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) msg = message(msg) { exp_str = mu_pp(exp) -- cgit v1.2.3