1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-11-02 12:29:33 +00:00
parent d49fca8894
commit fe1ad67c28
2 changed files with 18 additions and 4 deletions

View file

@ -89,11 +89,13 @@ module Test
}
return e
ensure
unless e
exp = exp.first if exp.size == 1
flunk(message(msg) {"#{mu_pp(exp)} expected but nothing was raised"})
end
end
exp = exp.first if exp.size == 1
flunk(message(msg) {"#{mu_pp(exp)} expected but nothing was raised"})
end
def assert_raises(*exp, &b)

View file

@ -14,4 +14,16 @@ class TestAssertion < Test::Unit::TestCase
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