Refactor exception handling in assert

This commit is contained in:
KOBAYASHI Shuji
2019-02-21 17:44:45 +09:00
parent baf8fbe6ed
commit ad789944db
+7 -9
View File
@@ -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