2 * Testing file for the extended syntax of the CALL instruction introduced
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.
14 * Check the version. Starting with 3.3RC1c we support the extended call
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."
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 )
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."
39 * Test the OS to determine the way we can remove a file.
42 if os
= 'UNIX' | os
= 'BEOS' | os
= 'QNX' | os
= 'AMIGA' | os
= 'LINUX' then
48 * Test for a debugging version of Regina.
50 QUEUE "options NOEXT_COMMANDS_AS_FUNCS; call dumptree; exit 0"
53 ADDRESS REXX
"" WITH INPUT FIFO
"" OUTPUT FIFO
"" ERROR FIFO
""
57 dumptree
= "call dumptree"
62 * Be sure our generated scripts will be invoked first.
64 OLD_MACRO_PATH
= value( "REGINA_MACROS", , "SYSTEM")
65 call value "REGINA_MACRO_PATH", directory(), "SYSTEM"
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"
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" )
182 call value "REGINA_MACRO_PATH", OLD_MACRO_PATH
, "SYSTEM"
184 call lineout "stderr", ""
185 call lineout "stderr", "Some tests didn't pass successfully."
186 call lineout "stderr", "Please, check the standard output log."
190 say "All tests passed successfully."
193 check: procedure expose dumptree
194 a
= dumptree
|| ";" strip( arg( 1 ) ) || "; return RESULT"
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
.
203 call value "REGINA_OPTIONS", "CALLS_AS_FUNCS", "SYSTEM"
204 address REXX
"TST.rexx" with output stem o1
. error stem e1
.
209 if rs0
>= 0 & rc0
> 100 & arg( 2 ) \
= "" then do
210 match
= "Error" arg( 2 )
213 if left( e0
.i
, ml
) = match
then do
219 if rs0
>= 0 & rc0
= arg( 4 ) then
222 if rs1
>= 0 & rc1
> 100 & arg( 3 ) \
= "" then do
223 match
= "Error" arg( 3 )
226 if left( e1
.i
, ml
) = match
then do
232 if rs1
>= 0 & rc1
= arg( 4 ) then
239 say "=========================================================================="
245 say "0O" || right( i
, 2, "0" ) || ":" o0
.i
248 say "0E" || right( i
, 2, "0" ) || ":" e0
.i
255 say "1O" || right( i
, 2, "0" ) || ":" o1
.i
258 say "1E" || right( i
, 2, "0" ) || ":" e1
.i