From 6fa352271f9bdfe1c86f0d29df4e56bdb2eabcd3 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 18 Oct 2008 04:41:17 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 ++++ lib/test/unit.rb | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 811e6a2c36..c59b84edab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Oct 18 13:40:27 2008 Tanaka Akira + + * lib/test/unit.rb (assert_nothing_thrown): implemented. + Sat Oct 18 01:33:22 2008 WATANABE Hirofumi * common.mk: use added options for generic_erb.rb. 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)