From 246ff7cb68aedfa2847395287a561d05a898fafe Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 17 Sep 2013 06:52:33 +0000 Subject: assertions.rb: assert_nothing_thrown returns the result * lib/test/unit/assertions.rb (Test::Unit::Assertions#assert_nothing_thrown): returns the result of the given block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/test/unit/assertions.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/test') diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb index 3d8a698b0d..0c919394ab 100644 --- a/lib/test/unit/assertions.rb +++ b/lib/test/unit/assertions.rb @@ -149,7 +149,8 @@ module Test # :call-seq: # assert_nothing_thrown( failure_message = nil, &block ) # - #Fails if the given block uses a call to Kernel#throw. + #Fails if the given block uses a call to Kernel#throw, and + #returns the result of the block otherwise. # #An optional failure message may be provided as the final argument. # @@ -158,13 +159,14 @@ module Test # end def assert_nothing_thrown(msg=nil) begin - yield + ret = yield rescue ArgumentError => error raise error if /\Auncaught throw (.+)\z/m !~ error.message msg = message(msg) { "<#{$1}> was thrown when nothing was expected" } flunk(msg) end assert(true, "Expected nothing to be thrown") + ret end # :call-seq: -- cgit v1.2.3