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:
parent
d49fca8894
commit
fe1ad67c28
2 changed files with 18 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue