mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Refactor exception handling in assert
This commit is contained in:
+7
-9
@@ -47,23 +47,21 @@ def assert(str = 'Assertion failed', iso = '')
|
||||
$mrbtest_assert_idx = 0
|
||||
yield
|
||||
if($mrbtest_assert.size > 0)
|
||||
$asserts.push(assertion_string('Fail: ', str, iso, nil))
|
||||
$asserts.push(assertion_string('Fail: ', str, iso))
|
||||
$ko_test += 1
|
||||
t_print('F')
|
||||
else
|
||||
$ok_test += 1
|
||||
t_print('.')
|
||||
end
|
||||
rescue MRubyTestSkip => e
|
||||
$asserts.push(assertion_string('Skip: ', str, iso, e))
|
||||
t_print('?')
|
||||
rescue Exception => e
|
||||
bt = e.backtrace if $mrbtest_verbose
|
||||
if e.class.to_s == 'MRubyTestSkip'
|
||||
$asserts.push(assertion_string('Skip: ', str, iso, e, nil))
|
||||
t_print('?')
|
||||
else
|
||||
$asserts.push(assertion_string("#{e.class}: ", str, iso, e, bt))
|
||||
$kill_test += 1
|
||||
t_print('X')
|
||||
end
|
||||
$asserts.push(assertion_string("#{e.class}: ", str, iso, e, bt))
|
||||
$kill_test += 1
|
||||
t_print('X')
|
||||
ensure
|
||||
$mrbtest_assert = nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user