blob: 54b50138e8431e447f46b30e33844d9cf5d2fee1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
$ok_test = 0
$ko_test = 0
$kill_test = 0
$asserts = []
##
# 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.
#
# str : A remark which will be printed in case
# this assertion fails
# iso : The ISO reference code of the feature
# which will be tested by this
# assertion
def assert(str = 'Assertion failed', iso = 'No ISO')
begin
if(!yield)
$asserts.push([str, iso])
$ko_test += 1
print('F')
else
$ok_test += 1
print('.')
end
rescue
$kill_test += 1
print('X')
end
end
##
# Report the test result and print all assertions
# which were reported broken.
def report()
print "\n"
$asserts.each do |str, iso|
print('Fail: ');
print_assertion_string(str, iso)
print("\n")
end
$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('Crash: ')
print($kill_test)
print("\n")
end
|