summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/test/unit/assertions.rb6
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 65752a0eb8..57328b05aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep 17 15:52:32 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@segment7.net>
* doc/regexp.rdoc: [DOC] Replace paragraphs in verbatim sections with
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: