diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-17 06:52:33 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-17 06:52:33 +0000 |
commit | 246ff7cb68aedfa2847395287a561d05a898fafe (patch) | |
tree | 3999a923b0e13a5e1734da712da65638a4720592 /lib/test | |
parent | 4afabb5a88f068b1aef851b8139d61687be9f427 (diff) |
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
Diffstat (limited to 'lib/test')
-rw-r--r-- | lib/test/unit/assertions.rb | 6 |
1 files changed, 4 insertions, 2 deletions
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: |