Debian Codegraph @

trip/lostdigits.rexx

raw
1 /*
2 * This is a simple test program for all the different occurances of possible
3 * LOSTDIGITS conditions of Regina.
4 *
5 * Every error message is writen to standard error.
6 * One line is written to standard output on success.
7 *
8 * Return codes: 0 on success, 1 otherwise
9 */
10 errors = 0
11 written = 0
12
13 call notify 'digits 5'
14 numeric digits 5
15 call doTest
16 call notify 'digits 4'
17 numeric digits 4
18 call doTest
19 if errors = 0 then do
20 exit 0
21 end
22 exit 1
23
24 doTest:
25 signal on lostdigits name addlost
26 b = 10001 + 1
27 adddone:
28 if digits() <= 4 then
29 call error "LOSTDIGITS not raised in addition, but needs to"
30 signal addend
31
32 addlost:
33 if digits() > 4 then
34 call error "LOSTDIGITS raised in addition, but must not"
35
36 addend:
37 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38
39 signal on lostdigits name sublost
40 b = -10001 - 1
41 subdone:
42 if digits() <= 4 then
43 call error "LOSTDIGITS not raised in subtraction, but needs to"
44 signal subend
45
46 sublost:
47 if digits() > 4 then
48 call error "LOSTDIGITS raised in subtraction, but must not"
49
50 subend:
51 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
52
53 signal on lostdigits name mullost
54 b = 1.0001 * 2
55 muldone:
56 if digits() <= 4 then
57 call error "LOSTDIGITS not raised in multiplication, but needs to"
58 signal mulend
59
60 mullost:
61 if digits() > 4 then
62 call error "LOSTDIGITS raised in multiplication, but must not"
63
64 mulend:
65 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
66
67 signal on lostdigits name fdivlost
68 b = 1.0001 / 2
69 fdivdone:
70 if digits() <= 4 then
71 call error "LOSTDIGITS not raised in decimal division, but needs to"
72 signal fdivend
73
74 fdivlost:
75 if digits() > 4 then
76 call error "LOSTDIGITS raised in decimal division, but must not"
77
78 fdivend:
79 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
80
81 signal on lostdigits name idivlost
82 b = 1.0001 % 2
83 idivdone:
84 if digits() <= 4 then
85 call error "LOSTDIGITS not raised in integer division, but needs to"
86 signal idivend
87
88 idivlost:
89 if digits() > 4 then
90 call error "LOSTDIGITS raised in integer division, but must not"
91
92 idivend:
93 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
94
95 signal on lostdigits name powlost
96 b = 8.0001 ** -2
97 powdone:
98 if digits() <= 4 then
99 call error "LOSTDIGITS not raised in power expression, but needs to"
100 signal powend
101
102 powlost:
103 if digits() > 4 then
104 call error "LOSTDIGITS raised in power expression, but must not"
105
106 powend:
107
108 return
109
110 error:
111 call lineout "<stderr>", arg(1)
112 errors = errors + 1
113 return
114
115 notify:
116 parse arg word
117 written = written + length(word) + 2
118 if written>75 then do
119 written = length(word)
120 say ' '
121 end
122 call charout , word || ', '
123 return