ruby-changes:30880
From: nobu <ko1@a...>
Date: Tue, 17 Sep 2013 15:52:40 +0900 (JST)
Subject: [ruby-changes:30880] nobu:r42959 (trunk): assertions.rb: assert_nothing_thrown returns the result
nobu 2013-09-17 15:52:33 +0900 (Tue, 17 Sep 2013) New Revision: 42959 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42959 Log: 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. Modified files: trunk/ChangeLog trunk/lib/test/unit/assertions.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42958) +++ ChangeLog (revision 42959) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 17 15:52:32 2013 Nobuyoshi Nakada <nobu@r...> + + * lib/test/unit/assertions.rb (Test::Unit::Assertions#assert_nothing_thrown): + returns the result of the given block. + Tue Sep 17 12:55:58 2013 Eric Hodel <drbrain@s...> * doc/regexp.rdoc: [DOC] Replace paragraphs in verbatim sections with Index: lib/test/unit/assertions.rb =================================================================== --- lib/test/unit/assertions.rb (revision 42958) +++ lib/test/unit/assertions.rb (revision 42959) @@ -149,7 +149,8 @@ module Test https://github.com/ruby/ruby/blob/trunk/lib/test/unit/assertions.rb#L149 # :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 https://github.com/ruby/ruby/blob/trunk/lib/test/unit/assertions.rb#L159 # 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: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/