Commit 21bd5d79 authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

print description on exceptions

parent 84a2fb10
...@@ -22,17 +22,18 @@ end ...@@ -22,17 +22,18 @@ end
# iso : The ISO reference code of the feature # iso : The ISO reference code of the feature
# which will be tested by this # which will be tested by this
# assertion # assertion
def assert(str = 'Assertion failed', iso = 'No ISO') def assert(str = 'Assertion failed', iso = '')
begin begin
if(!yield) if(!yield)
$asserts.push([str, iso]) $asserts.push(['Fail: ', str, iso])
$ko_test += 1 $ko_test += 1
print('F') print('F')
else else
$ok_test += 1 $ok_test += 1
print('.') print('.')
end end
rescue rescue => e
$asserts.push(['Error: ', str, iso, e])
$kill_test += 1 $kill_test += 1
print('X') print('X')
end end
...@@ -43,9 +44,13 @@ end ...@@ -43,9 +44,13 @@ end
# which were reported broken. # which were reported broken.
def report() def report()
print "\n" print "\n"
$asserts.each do |str, iso| $asserts.each do |err, str, iso, e|
print('Fail: '); print(err);
print_assertion_string(str, iso) print_assertion_string(str, iso)
if e
print(" => ")
print(e.message)
end
print("\n") print("\n")
end end
......
...@@ -23,8 +23,8 @@ assert('Time#initialize_copy', '15.2.19.7.17') do ...@@ -23,8 +23,8 @@ assert('Time#initialize_copy', '15.2.19.7.17') do
end end
assert('Time#mday', '15.2.19.7.19') do assert('Time#mday', '15.2.19.7.19') do
Time.gm(2012, 12, 23).mday == 23 Time.gm(2012, 12, 23).mday == 23
end end
assert('Time#month', '15.2.19.7.22') do assert('Time#month', '15.2.19.7.22') do
Time.gm(2012, 12, 23).month == 12 Time.gm(2012, 12, 23).month == 12
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment