ruby-changes:8300
From: akr <ko1@a...>
Date: Sat, 18 Oct 2008 13:42:06 +0900 (JST)
Subject: [ruby-changes:8300] Ruby:r19828 (trunk): * lib/test/unit.rb (assert_nothing_thrown): implemented.
akr 2008-10-18 13:41:17 +0900 (Sat, 18 Oct 2008) New Revision: 19828 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19828 Log: * lib/test/unit.rb (assert_nothing_thrown): implemented. Modified files: trunk/ChangeLog trunk/lib/test/unit.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19827) +++ ChangeLog (revision 19828) @@ -1,3 +1,7 @@ +Sat Oct 18 13:40:27 2008 Tanaka Akira <akr@f...> + + * lib/test/unit.rb (assert_nothing_thrown): implemented. + Sat Oct 18 01:33:22 2008 WATANABE Hirofumi <eban@r...> * common.mk: use added options for generic_erb.rb. Index: lib/test/unit.rb =================================================================== --- lib/test/unit.rb (revision 19827) +++ lib/test/unit.rb (revision 19828) @@ -48,7 +48,7 @@ begin require f rescue LoadError - puts $! + puts "#{f}: #{$!}" end } @@ -79,7 +79,7 @@ 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 @@ 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/