ruby-changes:48499
From: nobu <ko1@a...>
Date: Thu, 2 Nov 2017 21:29:38 +0900 (JST)
Subject: [ruby-changes:48499] nobu:r60614 (trunk): assertions.rb: fix return in assert_raise
nobu 2017-11-02 21:29:33 +0900 (Thu, 02 Nov 2017) New Revision: 60614 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60614 Log: assertions.rb: fix return in assert_raise * test/lib/test/unit/assertions.rb (assert_raise): should fail if returned gently in the given block without any exceptions. Modified files: trunk/test/lib/test/unit/assertions.rb trunk/test/testunit/test_assertion.rb Index: test/testunit/test_assertion.rb =================================================================== --- test/testunit/test_assertion.rb (revision 60613) +++ test/testunit/test_assertion.rb (revision 60614) @@ -14,4 +14,16 @@ class TestAssertion < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/testunit/test_assertion.rb#L14 end; end end + + def return_in_assert_raise + assert_raise(RuntimeError) do + return + end + end + + def test_assert_raise + assert_raise(MiniTest::Assertion) do + return_in_assert_raise + end + end end Index: test/lib/test/unit/assertions.rb =================================================================== --- test/lib/test/unit/assertions.rb (revision 60613) +++ test/lib/test/unit/assertions.rb (revision 60614) @@ -89,11 +89,13 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L89 } return e - end - - exp = exp.first if exp.size == 1 + ensure + unless e + exp = exp.first if exp.size == 1 - flunk(message(msg) {"#{mu_pp(exp)} expected but nothing was raised"}) + flunk(message(msg) {"#{mu_pp(exp)} expected but nothing was raised"}) + end + end end def assert_raises(*exp, &b) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/