Commit 769a7e0e authored by Daniel Bovensiepen's avatar Daniel Bovensiepen

handle exceptions in tests and reduce syntax features in assert code

parent f202658d
$ok_test = 0
$ko_test = 0
$kill_test = 0
$asserts = []
$exceptions = []
##
# Print the assertion in a readable way
def print_assertion_string(str, iso)
print(str)
if(iso != '')
print(' [')
print(iso)
print(']')
end
end
##
# Verify a code block.
......@@ -11,13 +24,18 @@ $asserts = []
# which will be tested by this
# assertion
def assert(str = 'Assertion failed', iso = '')
begin
if(!yield)
$asserts.push([str, iso])
$ko_test += 1
print "F"
print('F')
else
$ok_test += 1
print "."
print('.')
end
rescue
$kill_test += 1
print('X')
end
end
......@@ -27,18 +45,23 @@ end
def report()
print "\n"
$asserts.each do |str, iso|
print("Test Failed: #{str} [#{iso}]\n");
print('Fail: ');
print_assertion_string(str, iso)
print("\n")
end
$total_test = $ok_test + $ko_test
print 'Total tests:'
print $total_test
print "\n"
$total_test = $ok_test.+($ko_test)
print('Total: ')
print($total_test)
print("\n")
print ' OK: '
print $ok_test
print "\n"
print ' KO: '
print $ko_test
print "\n"
print(' OK: ')
print($ok_test)
print("\n")
print(' KO: ')
print($ko_test)
print("\n")
print(' Crash: ')
print($kill_test)
print("\n")
end
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