mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Allowed to pass multiple exceptions to assert_raise
This commit is contained in:
+4
-2
@@ -143,17 +143,19 @@ def assert_not_include(collection, obj, msg = nil)
|
||||
assert_false(collection.include?(obj), msg, diff)
|
||||
end
|
||||
|
||||
def assert_raise(exc, msg = nil)
|
||||
def assert_raise(*exc)
|
||||
return true unless $mrbtest_assert
|
||||
$mrbtest_assert_idx += 1
|
||||
|
||||
msg = (exc.last.is_a? String) ? exc.pop : nil
|
||||
|
||||
begin
|
||||
yield
|
||||
msg ||= "Expected to raise #{exc} but nothing was raised."
|
||||
diff = nil
|
||||
$mrbtest_assert.push [$mrbtest_assert_idx, msg, diff]
|
||||
false
|
||||
rescue exc
|
||||
rescue *exc
|
||||
true
|
||||
rescue Exception => e
|
||||
msg ||= "Expected to raise #{exc}, not"
|
||||
|
||||
Reference in New Issue
Block a user