Commit | Line | Data |
57ebbfd0 |
1 | #!./perl |
8990e307 |
2 | |
88587957 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
8990e307 |
7 | require "bigint.pl"; |
57ebbfd0 |
8 | |
9 | $test = 0; |
10 | $| = 1; |
11 | print "1..246\n"; |
12 | while (<DATA>) { |
13 | chop; |
14 | if (/^&/) { |
15 | $f = $_; |
16 | } else { |
17 | ++$test; |
18 | @args = split(/:/,$_,99); |
19 | $ans = pop(@args); |
20 | $try = "$f('" . join("','", @args) . "');"; |
21 | if (($ans1 = eval($try)) eq $ans) { |
22 | print "ok $test\n"; |
23 | } else { |
24 | print "not ok $test\n"; |
25 | print "# '$try' expected: '$ans' got: '$ans1'\n"; |
26 | } |
27 | } |
28 | } |
29 | __END__ |
30 | &bnorm |
31 | abc:NaN |
32 | 1 a:NaN |
33 | 1bcd2:NaN |
34 | 11111b:NaN |
35 | +1z:NaN |
36 | -1z:NaN |
37 | 0:+0 |
38 | +0:+0 |
39 | +00:+0 |
40 | +0 0 0:+0 |
41 | 000000 0000000 00000:+0 |
42 | -0:+0 |
43 | -0000:+0 |
44 | +1:+1 |
45 | +01:+1 |
46 | +001:+1 |
47 | +00000100000:+100000 |
48 | 123456789:+123456789 |
49 | -1:-1 |
50 | -01:-1 |
51 | -001:-1 |
52 | -123456789:-123456789 |
53 | -00000100000:-100000 |
54 | &bneg |
55 | abd:NaN |
56 | +0:+0 |
57 | +1:-1 |
58 | -1:+1 |
59 | +123456789:-123456789 |
60 | -123456789:+123456789 |
61 | &babs |
62 | abc:NaN |
63 | +0:+0 |
64 | +1:+1 |
65 | -1:+1 |
66 | +123456789:+123456789 |
67 | -123456789:+123456789 |
68 | &bcmp |
69 | abc:abc: |
70 | abc:+0: |
71 | +0:abc: |
72 | +0:+0:0 |
73 | -1:+0:-1 |
74 | +0:-1:1 |
75 | +1:+0:1 |
76 | +0:+1:-1 |
77 | -1:+1:-1 |
78 | +1:-1:1 |
79 | -1:-1:0 |
80 | +1:+1:0 |
81 | +123:+123:0 |
82 | +123:+12:1 |
83 | +12:+123:-1 |
84 | -123:-123:0 |
85 | -123:-12:-1 |
86 | -12:-123:1 |
87 | +123:+124:-1 |
88 | +124:+123:1 |
89 | -123:-124:1 |
90 | -124:-123:-1 |
91 | &badd |
92 | abc:abc:NaN |
93 | abc:+0:NaN |
94 | +0:abc:NaN |
95 | +0:+0:+0 |
96 | +1:+0:+1 |
97 | +0:+1:+1 |
98 | +1:+1:+2 |
99 | -1:+0:-1 |
100 | +0:-1:-1 |
101 | -1:-1:-2 |
102 | -1:+1:+0 |
103 | +1:-1:+0 |
104 | +9:+1:+10 |
105 | +99:+1:+100 |
106 | +999:+1:+1000 |
107 | +9999:+1:+10000 |
108 | +99999:+1:+100000 |
109 | +999999:+1:+1000000 |
110 | +9999999:+1:+10000000 |
111 | +99999999:+1:+100000000 |
112 | +999999999:+1:+1000000000 |
113 | +9999999999:+1:+10000000000 |
114 | +99999999999:+1:+100000000000 |
115 | +10:-1:+9 |
116 | +100:-1:+99 |
117 | +1000:-1:+999 |
118 | +10000:-1:+9999 |
119 | +100000:-1:+99999 |
120 | +1000000:-1:+999999 |
121 | +10000000:-1:+9999999 |
122 | +100000000:-1:+99999999 |
123 | +1000000000:-1:+999999999 |
124 | +10000000000:-1:+9999999999 |
125 | +123456789:+987654321:+1111111110 |
126 | -123456789:+987654321:+864197532 |
127 | -123456789:-987654321:-1111111110 |
128 | +123456789:-987654321:-864197532 |
129 | &bsub |
130 | abc:abc:NaN |
131 | abc:+0:NaN |
132 | +0:abc:NaN |
133 | +0:+0:+0 |
134 | +1:+0:+1 |
135 | +0:+1:-1 |
136 | +1:+1:+0 |
137 | -1:+0:-1 |
138 | +0:-1:+1 |
139 | -1:-1:+0 |
140 | -1:+1:-2 |
141 | +1:-1:+2 |
142 | +9:+1:+8 |
143 | +99:+1:+98 |
144 | +999:+1:+998 |
145 | +9999:+1:+9998 |
146 | +99999:+1:+99998 |
147 | +999999:+1:+999998 |
148 | +9999999:+1:+9999998 |
149 | +99999999:+1:+99999998 |
150 | +999999999:+1:+999999998 |
151 | +9999999999:+1:+9999999998 |
152 | +99999999999:+1:+99999999998 |
153 | +10:-1:+11 |
154 | +100:-1:+101 |
155 | +1000:-1:+1001 |
156 | +10000:-1:+10001 |
157 | +100000:-1:+100001 |
158 | +1000000:-1:+1000001 |
159 | +10000000:-1:+10000001 |
160 | +100000000:-1:+100000001 |
161 | +1000000000:-1:+1000000001 |
162 | +10000000000:-1:+10000000001 |
163 | +123456789:+987654321:-864197532 |
164 | -123456789:+987654321:-1111111110 |
165 | -123456789:-987654321:+864197532 |
166 | +123456789:-987654321:+1111111110 |
167 | &bmul |
168 | abc:abc:NaN |
169 | abc:+0:NaN |
170 | +0:abc:NaN |
171 | +0:+0:+0 |
172 | +0:+1:+0 |
173 | +1:+0:+0 |
174 | +0:-1:+0 |
175 | -1:+0:+0 |
176 | +123456789123456789:+0:+0 |
177 | +0:+123456789123456789:+0 |
178 | -1:-1:+1 |
179 | -1:+1:-1 |
180 | +1:-1:-1 |
181 | +1:+1:+1 |
182 | +2:+3:+6 |
183 | -2:+3:-6 |
184 | +2:-3:-6 |
185 | -2:-3:+6 |
186 | +111:+111:+12321 |
187 | +10101:+10101:+102030201 |
188 | +1001001:+1001001:+1002003002001 |
189 | +100010001:+100010001:+10002000300020001 |
190 | +10000100001:+10000100001:+100002000030000200001 |
191 | +11111111111:+9:+99999999999 |
192 | +22222222222:+9:+199999999998 |
193 | +33333333333:+9:+299999999997 |
194 | +44444444444:+9:+399999999996 |
195 | +55555555555:+9:+499999999995 |
196 | +66666666666:+9:+599999999994 |
197 | +77777777777:+9:+699999999993 |
198 | +88888888888:+9:+799999999992 |
199 | +99999999999:+9:+899999999991 |
200 | &bdiv |
201 | abc:abc:NaN |
202 | abc:+1:abc:NaN |
203 | +1:abc:NaN |
204 | +0:+0:NaN |
205 | +0:+1:+0 |
206 | +1:+0:NaN |
207 | +0:-1:+0 |
208 | -1:+0:NaN |
209 | +1:+1:+1 |
210 | -1:-1:+1 |
211 | +1:-1:-1 |
212 | -1:+1:-1 |
213 | +1:+2:+0 |
214 | +2:+1:+2 |
215 | +1000000000:+9:+111111111 |
216 | +2000000000:+9:+222222222 |
217 | +3000000000:+9:+333333333 |
218 | +4000000000:+9:+444444444 |
219 | +5000000000:+9:+555555555 |
220 | +6000000000:+9:+666666666 |
221 | +7000000000:+9:+777777777 |
222 | +8000000000:+9:+888888888 |
223 | +9000000000:+9:+1000000000 |
224 | +35500000:+113:+314159 |
225 | +71000000:+226:+314159 |
226 | +106500000:+339:+314159 |
227 | +1000000000:+3:+333333333 |
228 | +10:+5:+2 |
229 | +100:+4:+25 |
230 | +1000:+8:+125 |
231 | +10000:+16:+625 |
232 | +999999999999:+9:+111111111111 |
233 | +999999999999:+99:+10101010101 |
234 | +999999999999:+999:+1001001001 |
235 | +999999999999:+9999:+100010001 |
236 | +999999999999999:+99999:+10000100001 |
237 | &bmod |
238 | abc:abc:NaN |
239 | abc:+1:abc:NaN |
240 | +1:abc:NaN |
241 | +0:+0:NaN |
242 | +0:+1:+0 |
243 | +1:+0:NaN |
244 | +0:-1:+0 |
245 | -1:+0:NaN |
246 | +1:+1:+0 |
247 | -1:-1:+0 |
248 | +1:-1:+0 |
249 | -1:+1:+0 |
250 | +1:+2:+1 |
251 | +2:+1:+0 |
252 | +1000000000:+9:+1 |
253 | +2000000000:+9:+2 |
254 | +3000000000:+9:+3 |
255 | +4000000000:+9:+4 |
256 | +5000000000:+9:+5 |
257 | +6000000000:+9:+6 |
258 | +7000000000:+9:+7 |
259 | +8000000000:+9:+8 |
260 | +9000000000:+9:+0 |
261 | +35500000:+113:+33 |
262 | +71000000:+226:+66 |
263 | +106500000:+339:+99 |
264 | +1000000000:+3:+1 |
265 | +10:+5:+0 |
266 | +100:+4:+0 |
267 | +1000:+8:+0 |
268 | +10000:+16:+0 |
269 | +999999999999:+9:+0 |
270 | +999999999999:+99:+0 |
271 | +999999999999:+999:+0 |
272 | +999999999999:+9999:+0 |
273 | +999999999999999:+99999:+0 |
274 | &bgcd |
275 | abc:abc:NaN |
276 | abc:+0:NaN |
277 | +0:abc:NaN |
278 | +0:+0:+0 |
279 | +0:+1:+1 |
280 | +1:+0:+1 |
281 | +1:+1:+1 |
282 | +2:+3:+1 |
283 | +3:+2:+1 |
284 | +100:+625:+25 |
285 | +4096:+81:+1 |