| 1 |
/* |
| 2 |
* Testing file for the extended syntax of the CALL instruction introduced |
| 3 |
* in Regina 3.3. |
| 4 |
* |
| 5 |
* Usage: rexx lexical2 [>output] |
| 6 |
* If an error occurs one message with one line is written to standard error |
| 7 |
* and the exit code is 1. The redirected output should be send to the |
| 8 |
* maintainers of Regina to fix the behaviour. |
| 9 |
* On success "All tests passed successfully." is written to standard output |
| 10 |
* and the exit code is 0. |
| 11 |
*/ |
| 12 |
|
| 13 |
/* |
| 14 |
* Check the version. Starting with 3.3RC1c we support the extended call |
| 15 |
* syntax again. |
| 16 |
*/ |
| 17 |
parse version "REXX-"regina"_"v . |
| 18 |
if regina \= "Regina" then do |
| 19 |
call lineout ,"Your REXX interpreter is not smart enough for this test." |
| 20 |
exit 1 |
| 21 |
end |
| 22 |
|
| 23 |
sub = "" |
| 24 |
do len = 3 to length(v) |
| 25 |
if \datatype( left( v, len ), "N" ) then do |
| 26 |
sub = substr( v, len ) |
| 27 |
v = left( v, len - 1 ) |
| 28 |
leave |
| 29 |
end |
| 30 |
end |
| 31 |
|
| 32 |
if v < 3.3 | ( v == "3.3" & ( sub < "RC1c" | left( sub, 4 ) = "beta" ) ) then do |
| 33 |
call lineout ,"Your Regina interpreter is not smart enough for this test." |
| 34 |
exit 1 |
| 35 |
end |
| 36 |
drop len v sub |
| 37 |
|
| 38 |
/* |
| 39 |
* Test the OS to determine the way we can remove a file. |
| 40 |
*/ |
| 41 |
parse source os . |
| 42 |
if os = 'UNIX' | os = 'BEOS' | os = 'QNX' | os = 'AMIGA' | os = 'LINUX' then |
| 43 |
osdel1 = 'rm -f' |
| 44 |
else |
| 45 |
osdel1 = 'del' |
| 46 |
|
| 47 |
/* |
| 48 |
* Test for a debugging version of Regina. |
| 49 |
*/ |
| 50 |
QUEUE "options NOEXT_COMMANDS_AS_FUNCS; call dumptree; exit 0" |
| 51 |
t = trace() |
| 52 |
trace o |
| 53 |
ADDRESS REXX "" WITH INPUT FIFO "" OUTPUT FIFO "" ERROR FIFO "" |
| 54 |
trace value t |
| 55 |
call desbuf |
| 56 |
if rc = 0 then |
| 57 |
dumptree = "call dumptree" |
| 58 |
else |
| 59 |
dumptree = "" |
| 60 |
|
| 61 |
/* |
| 62 |
* Be sure our generated scripts will be invoked first. |
| 63 |
*/ |
| 64 |
OLD_MACRO_PATH = value( "REGINA_MACROS", , "SYSTEM") |
| 65 |
call value "REGINA_MACRO_PATH", directory(), "SYSTEM" |
| 66 |
|
| 67 |
call stream "A.rexx", "C", "OPEN WRITE REPLACE" |
| 68 |
call lineout "A.rexx", 'say "arguments: " arg()' |
| 69 |
call lineout "A.rexx", 'retval = 10' |
| 70 |
call lineout "A.rexx", 'do i = 1 to arg()' |
| 71 |
call lineout "A.rexx", ' if arg( i,'O' ) then ' |
| 72 |
call lineout "A.rexx", ' iterate' |
| 73 |
call lineout "A.rexx", ' say "argument" i || ":" arg( i )' |
| 74 |
call lineout "A.rexx", ' retval = retval + 2**i + arg( i ) * i' |
| 75 |
call lineout "A.rexx", ' end' |
| 76 |
call lineout "A.rexx", 'say "returning" retval' |
| 77 |
call lineout "A.rexx", 'exit retval' |
| 78 |
call stream "A.rexx", "C", "CLOSE" |
| 79 |
|
| 80 |
errs = 0 |
| 81 |
errs = errs + check( "a=1,2 ", "64.1", "64.1", "" ) |
| 82 |
errs = errs + check( "a=( ", "36" , "36" , "" ) |
| 83 |
errs = errs + check( "a=() ", "37" , "37" , "" ) |
| 84 |
errs = errs + check( "a=(,3) ", "37.1", "37.1", "" ) |
| 85 |
errs = errs + check( "a=(2,) ", "37.1", "37.1", "" ) |
| 86 |
errs = errs + check( "a=(2,3) ", "37.1", "37.1", "" ) |
| 87 |
errs = errs + check( "a=(()) ", "37" , "37" , "" ) |
| 88 |
errs = errs + check( "a=((,3)) ", "37.1", "37.1", "" ) |
| 89 |
errs = errs + check( "a=((2,)) ", "37.1", "37.1", "" ) |
| 90 |
errs = errs + check( "a=((2,3)) ", "37.1", "37.1", "" ) |
| 91 |
errs = errs + check( "a=(2+(2,3)) ", "37.1", "37.1", "" ) |
| 92 |
errs = errs + check( "a=(2,3+2) ", "37.1", "37.1", "" ) |
| 93 |
errs = errs + check( "a=((2,3+2)) ", "37.1", "37.1", "" ) |
| 94 |
errs = errs + check( "a=((2,3+2)+2) ", "37.1", "37.1", "" ) |
| 95 |
errs = errs + check( "a=(1,,,4) ", "37.1", "37.1", "" ) |
| 96 |
errs = errs + check( "a=(1,,,(3,4)) ", "37.1", "37.1", "" ) |
| 97 |
errs = errs + check( "a=((1,2),,,4) ", "37.1", "37.1", "" ) |
| 98 |
errs = errs + check( "result=a( ", "36" , "36" , "" ) |
| 99 |
errs = errs + check( "result=a() ", "" , "" , "10" ) |
| 100 |
errs = errs + check( "result=a(,3) ", "" , "" , "20" ) |
| 101 |
errs = errs + check( "result=a(2,) ", "" , "" , "14" ) |
| 102 |
errs = errs + check( "result=a(2,3) ", "" , "" , "24" ) |
| 103 |
errs = errs + check( "result=a(()) ", "37" , "37" , "" ) |
| 104 |
errs = errs + check( "result=a((,3)) ", "37.1", "37.1", "" ) |
| 105 |
errs = errs + check( "result=a((2,)) ", "37.1", "37.1", "" ) |
| 106 |
errs = errs + check( "result=a((2,3)) ", "37.1", "37.1", "" ) |
| 107 |
errs = errs + check( "result=a(2+(2,3)) ", "37.1", "37.1", "" ) |
| 108 |
errs = errs + check( "result=a(2,3+2) ", "" , "" , "28" ) |
| 109 |
errs = errs + check( "result=a((2,3+2)) ", "37.1", "37.1", "" ) |
| 110 |
errs = errs + check( "result=a((2,3+2)+2) ", "37.1", "37.1", "" ) |
| 111 |
errs = errs + check( "result=a(1,,,4) ", "" , "" , "45" ) |
| 112 |
errs = errs + check( "result=a(1,,,(3,4)) ", "37.1", "37.1", "" ) |
| 113 |
errs = errs + check( "result=a((1,2),,,4) ", "37.1", "37.1", "" ) |
| 114 |
errs = errs + check( "call a( ", "36" , "36" , "" ) |
| 115 |
errs = errs + check( "call a() ", "37" , "" , "10" ) |
| 116 |
errs = errs + check( "call a () ", "37" , "" , "10" ) |
| 117 |
errs = errs + check( "call a() 1 ", "37" , "35" , "" ) |
| 118 |
errs = errs + check( "call a()+1 ", "37" , "35" , "" ) |
| 119 |
errs = errs + check( "call a 1 () ", "37" , "37" , "" ) |
| 120 |
errs = errs + check( "call a 1 (),2 ", "37" , "37" , "" ) |
| 121 |
errs = errs + check( "call a() 1,2 ", "37" , "35" , "" ) |
| 122 |
errs = errs + check( "call a ()1 ", "37" , "35" , "" ) |
| 123 |
errs = errs + check( "call a ()1,2 ", "37" , "35" , "" ) |
| 124 |
errs = errs + check( "call a (1)1 ", "" , "" , "23" ) |
| 125 |
errs = errs + check( "call a (1)1,2 ", "" , "" , "31" ) |
| 126 |
errs = errs + check( "call a(,3) ", "37.1", "" , "20" ) |
| 127 |
errs = errs + check( "call a(2,) ", "37.1", "" , "14" ) |
| 128 |
errs = errs + check( "call a(1 2) ", "" , "" , "0" ) |
| 129 |
errs = errs + check( "call a(1,2) (3) ", "37.1", "35" , "" ) |
| 130 |
errs = errs + check( "call a(1) (2) (3) ", "" , "" , "0" ) |
| 131 |
errs = errs + check( "call a(1) (2), (3) ", "" , "" , "0" ) |
| 132 |
errs = errs + check( "call a(2,3) ", "37.1", "" , "24" ) |
| 133 |
errs = errs + check( "call a(()) ", "37" , "37" , "" ) |
| 134 |
errs = errs + check( "call a((,3)) ", "37.1", "37.1", "" ) |
| 135 |
errs = errs + check( "call a((2,)) ", "37.1", "37.1", "" ) |
| 136 |
errs = errs + check( "call a((2,3)) ", "37.1", "37.1", "" ) |
| 137 |
errs = errs + check( "call a(2+(2,3)) ", "37.1", "37.1", "" ) |
| 138 |
errs = errs + check( "call a(2,3+2) ", "37.1", "" , "28" ) |
| 139 |
errs = errs + check( "call a((2,3+2)) ", "37.1", "37.1", "" ) |
| 140 |
errs = errs + check( "call a((2,3+2)+2) ", "37.1", "37.1", "" ) |
| 141 |
errs = errs + check( "call a(1,,,4) ", "37.1", "" , "45" ) |
| 142 |
errs = errs + check( "call a(1,,,(3,4)) ", "37.1", "37.1", "" ) |
| 143 |
errs = errs + check( "call a((1,2),,,4) ", "37.1", "37.1", "" ) |
| 144 |
errs = errs + check( "call a((())) ", "37" , "37" , "" ) |
| 145 |
errs = errs + check( "call a((2,())) ", "37.1", "37.1", "" ) |
| 146 |
errs = errs + check( "call a(((2,3))) ", "37.1", "37.1", "" ) |
| 147 |
errs = errs + check( "call a((2,(3))) ", "37.1", "37.1", "" ) |
| 148 |
errs = errs + check( "call a((2,(3+2))+2) ", "37.1", "37.1", "" ) |
| 149 |
errs = errs + check( "call a(((2,3+2))+2) ", "37.1", "37.1", "" ) |
| 150 |
errs = errs + check( "call a((1),,,(4)) ", "37.1", "" , "45" ) |
| 151 |
errs = errs + check( "call a((1)),,,(4)) ", "37.2", "37.2", "" ) |
| 152 |
errs = errs + check( "call a((1,2),,,4) ", "37.1", "37.1", "" ) |
| 153 |
errs = errs + check( "call a(((1,2)),,,4) ", "37.1", "37.1", "" ) |
| 154 |
errs = errs + check( "call a((1,2),,,(4)) ", "37.1", "37.1", "" ) |
| 155 |
errs = errs + check( "call a())) ", "37" , "37.2", "" ) |
| 156 |
errs = errs + check( "call a 2,() ", "37" , "37" , "" ) |
| 157 |
errs = errs + check( "call a (2,3) ", "37.1", "" , "24" ) |
| 158 |
errs = errs + check( "call a 2,(3) ", "" , "" , "24" ) |
| 159 |
errs = errs + check( "call a 2,(3+2)+2 ", "" , "" , "32" ) |
| 160 |
errs = errs + check( "call a (2,3+2)+2 ", "37.1", "35" , "" ) |
| 161 |
errs = errs + check( "call a 1,,,(4) ", "" , "" , "45" ) |
| 162 |
errs = errs + check( "call a (1),,,(4) ", "" , "" , "45" ) |
| 163 |
errs = errs + check( "call a (1+2),,,(3+4) ", "" , "" , "59" ) |
| 164 |
errs = errs + check( "call a 1+(2,3) ", "37.1", "37.1", "" ) |
| 165 |
errs = errs + check( "call a 1,,,4 ", "" , "" , "45" ) |
| 166 |
errs = errs + check( "call a 1 + 2,,,3 + 4 ", "" , "" , "59" ) |
| 167 |
errs = errs + check( "call a (1,2),,,4 ", "37.1", "37.1", "" ) |
| 168 |
errs = errs + check( "call a 1,,,(3,4) ", "37.1", "37.1", "" ) |
| 169 |
errs = errs + check( "call a a() ", "" , "" , "22" ) |
| 170 |
errs = errs + check( "call a ,a() + 1, ", "" , "" , "36" ) |
| 171 |
errs = errs + check( "call a ,trunc((1+2)),3 ", "" , "" , "37" ) |
| 172 |
errs = errs + check( "call a ,trunc((1+2),1),3 ", "" , "" , "37" ) |
| 173 |
errs = errs + check( "call a(a()) ", "" , "" , "22" ) |
| 174 |
errs = errs + check( "call a((a())) ", "" , "" , "22" ) |
| 175 |
errs = errs + check( "call a(,a() + 1,) ", "37.1", "" , "36" ) |
| 176 |
errs = errs + check( "call a(trunc((1+2))) ", "" , "" , "15" ) |
| 177 |
errs = errs + check( "call a(trunc((1+2),1)) ", "" , "" , "15" ) |
| 178 |
errs = errs + check( "call a(trunc((1+2)),1) ", "37.1", "" , "21" ) |
| 179 |
osdel1 "TST.rexx" |
| 180 |
osdel1 "A.rexx" |
| 181 |
|
| 182 |
call value "REGINA_MACRO_PATH", OLD_MACRO_PATH, "SYSTEM" |
| 183 |
if errs > 0 then do |
| 184 |
call lineout "stderr", "" |
| 185 |
call lineout "stderr", "Some tests didn't pass successfully." |
| 186 |
call lineout "stderr", "Please, check the standard output log." |
| 187 |
return 1 |
| 188 |
end |
| 189 |
|
| 190 |
say "All tests passed successfully." |
| 191 |
return 0 |
| 192 |
|
| 193 |
check: procedure expose dumptree |
| 194 |
a = dumptree || ";" strip( arg( 1 ) ) || "; return RESULT" |
| 195 |
t = trace() |
| 196 |
trace o |
| 197 |
call stream "TST.rexx", "C", "OPEN WRITE REPLACE" |
| 198 |
call lineout "TST.rexx", a |
| 199 |
call stream "TST.rexx", "C", "CLOSE" |
| 200 |
call value "REGINA_OPTIONS", "", "SYSTEM" |
| 201 |
address REXX "TST.rexx" with output stem o0. error stem e0. |
| 202 |
rs0 = .RS; rc0 = .RC |
| 203 |
call value "REGINA_OPTIONS", "CALLS_AS_FUNCS", "SYSTEM" |
| 204 |
address REXX "TST.rexx" with output stem o1. error stem e1. |
| 205 |
rs1 = .RS; rc1 = .RC |
| 206 |
trace value t |
| 207 |
|
| 208 |
v0 = 0; v1 = 0 |
| 209 |
if rs0 >= 0 & rc0 > 100 & arg( 2 ) \= "" then do |
| 210 |
match = "Error" arg( 2 ) |
| 211 |
ml = length( match ) |
| 212 |
do i = 1 to e0.0 |
| 213 |
if left( e0.i, ml ) = match then do |
| 214 |
v0 = 1 |
| 215 |
leave |
| 216 |
end |
| 217 |
end |
| 218 |
end |
| 219 |
if rs0 >= 0 & rc0 = arg( 4 ) then |
| 220 |
v0 = 1 |
| 221 |
|
| 222 |
if rs1 >= 0 & rc1 > 100 & arg( 3 ) \= "" then do |
| 223 |
match = "Error" arg( 3 ) |
| 224 |
ml = length( match ) |
| 225 |
do i = 1 to e1.0 |
| 226 |
if left( e1.i, ml ) = match then do |
| 227 |
v1 = 1 |
| 228 |
leave |
| 229 |
end |
| 230 |
end |
| 231 |
end |
| 232 |
if rs1 >= 0 & rc1 = arg( 4 ) then |
| 233 |
v1 = 1 |
| 234 |
|
| 235 |
if v0 & v1 then |
| 236 |
return 0 |
| 237 |
|
| 238 |
say "" |
| 239 |
say "==========================================================================" |
| 240 |
say a |
| 241 |
|
| 242 |
say "---" |
| 243 |
if \v0 then do |
| 244 |
do i = 1 to o0.0 |
| 245 |
say "0O" || right( i, 2, "0" ) || ":" o0.i |
| 246 |
end |
| 247 |
do i = 1 to e0.0 |
| 248 |
say "0E" || right( i, 2, "0" ) || ":" e0.i |
| 249 |
end |
| 250 |
end |
| 251 |
if \v0 & \v1 then |
| 252 |
say "----------" |
| 253 |
if \v1 then do |
| 254 |
do i = 1 to o1.0 |
| 255 |
say "1O" || right( i, 2, "0" ) || ":" o1.i |
| 256 |
end |
| 257 |
do i = 1 to e1.0 |
| 258 |
say "1E" || right( i, 2, "0" ) || ":" e1.i |
| 259 |
end |
| 260 |
end |
| 261 |
return 1 |
| 262 |
|