-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathassert.cbl
More file actions
142 lines (122 loc) · 4.28 KB
/
assert.cbl
File metadata and controls
142 lines (122 loc) · 4.28 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
identification division.
program-id. assert.
author. Luca Piccinelli.
date-written. 26.04.2020.
environment division.
configuration section.
special-names.
input-output section.
file-control.
data division.
file section.
working-storage section.
copy "definitions.cpy"
replacing ==!MAX-PARAMS-NUM== by ==4==.
78 VALUE-DIMENSION value 2048.
78 DESCRIPTION-DIMENSION value 2048.
77 w-operator pic x(16) value EQ.
77 w-expected pic x(VALUE-DIMENSION) value spaces.
77 w-actual pic x(VALUE-DIMENSION) value spaces.
77 w-description pic x(DESCRIPTION-DIMENSION)
value "empty description".
77 w-return-value pic 9(02) value 0.
77 w-display-decription pic x(256) value spaces.
77 w-string-pointer pic 9(18) value 0.
77 w-total-number-of-tests pic 9(09) value 0.
77 z-total-number-of-tests pic z(04)9.
77 w-success-number-of-tests pic 9(09) value 0.
77 z-success-number-of-tests pic z(04)9.
77 w-failed-number-of-tests pic 9(09) value 0.
77 z-failed-number-of-tests pic z(04)9.
77 w-verify-str pic x(256) value spaces.
linkage section.
77 l-operator pic x(MAX-LINKAGE).
77 l-expected pic x(MAX-LINKAGE).
77 l-actual pic x(MAX-LINKAGE).
77 l-description pic x(MAX-LINKAGE).
procedure division using
l-operator
l-expected
l-actual
l-description
.
$CATCHPARAMS.
copy "catchx.pdv" replacing
==!W== by ==operator==
==!N== by ==1==.
copy "catchx.pdv" replacing
==!W== by ==expected==
==!N== by ==2==.
copy "catchx.pdv" replacing
==!W== by ==actual==
==!N== by ==3==.
copy "catchx.pdv" replacing
==!W== by ==description==
==!N== by ==4==.
if w-operator = VERIFY
perform run-verify thru run-verify-ex
goback giving 0
end-if.
call "assert-logic"
using w-operator w-expected w-actual
giving w-return-value.
add 1 to w-total-number-of-tests.
initialize w-display-decription
move 1 to w-string-pointer.
if w-return-value = OK
add 1 to w-success-number-of-tests
string
"OK -- "
into w-display-decription
pointer w-string-pointer
end-string
else
add 1 to w-failed-number-of-tests
string
"KO -- "
into w-display-decription
pointer w-string-pointer
end-string
end-if.
string
w-description
delimited by STRING-LIMIT
into w-display-decription
pointer w-string-pointer
end-string.
if w-return-value = KO
string
" -- Expected "
w-expected
". It was instead "
w-actual
delimited by low-value
into w-display-decription
pointer w-string-pointer
end-string
end-if.
display w-display-decription upon console.
goback giving w-return-value.
run-verify.
move w-total-number-of-tests to z-total-number-of-tests.
move w-success-number-of-tests to z-success-number-of-tests.
move w-failed-number-of-tests to z-failed-number-of-tests.
initialize w-verify-str.
string
"RESULTS:"
z-total-number-of-tests
" were executed."
z-success-number-of-tests
" were OK."
z-failed-number-of-tests
" were KO."
into w-verify-str
end-string.
display w-verify-str upon console.
if w-failed-number-of-tests = 0
display "Test is OK" upon console
else
display "Test is KO" upon console
end-if.
run-verify-ex.
exit.