Debian Codegraph @

trip/addrtest2.rexx

raw
1 /*
2 * Generic test for CALL trapping of the conditions FAILURE and HALT.
3 * You need the program "rc" to run this script.
4 * The test gives some lines of debugging output.
5 *
6 * The test returns 1 and prints some lines to standard error in case of
7 * an error.
8 * The test returns 0 without any line written to stdardard error on success.
9 *
10 * A good testing environment does the following test; remove the redirection
11 * element in case of errors and check the output:
12 * "rexx addrtest2 >/dev/null"
13 */
14 call on failure name MustBeNoFail
15 call on error name MustBeNoErr
16
17 address path 'rc 0'
18
19 signal on error name MustBeError
20 address path 'rc 1'
21 call oops "not trapped in condition ERROR, but it should"
22 exit 1
23
24 MustBeError:
25 if .RS \= 1 then do
26 call oops ".RS not set correctly"
27 exit 1
28 end
29
30 call on error name MustBeNoErr
31 signal on failure name MustBeFailure
32 address path 'unknown_prg'
33 call oops "not trapped in condition FAILURE, but it should"
34 exit 1
35
36 MustBeFailure:
37 if .RS \= -1 then do
38 call oops ".RS not set correctly"
39 exit 1
40 end
41
42 say ""
43 say "test passed"
44 return 0
45
46 MustBeNoFail:
47 call oops "trapped in condition FAILURE without expectation"
48 exit 1
49
50 MustBeNoErr:
51 call oops "trapped in condition ERROR without expectation"
52 exit 1
53
54 oops: procedure
55 call lineout "<stderr>", "----------------------------------------"
56 call lineout "<stderr>", arg(1)
57 call lineout "<stderr>", "----------------------------------------"
58 call lineout "<stderr>", ""
59 exit 1
60 return