This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Suppress deprecation warnings from test output
[perl5.git] / lib / bigfloatpl.t
CommitLineData
5d7098d5
SK
1#!./perl
2
88587957
NC
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
96471c6b
JH
8{
9 # Silence the deprecation warnings from bigfloat.pl for the purpose
10 # of testing. These tests will be removed along with bigfloat.pl in
11 # the next major release of perl.
12 local $SIG{__WARN__} = sub {
13 if ($_[0] !~ /deprecated/) {
14 print(STDERR @_);
15 }
16 };
17 require "bigfloat.pl";
18}
5d7098d5
SK
19
20$test = 0;
21$| = 1;
22print "1..355\n";
23while (<DATA>) {
24 chop;
25 if (/^&/) {
26 $f = $_;
27 } elsif (/^\$.*/) {
28 eval "$_;";
29 } else {
30 ++$test;
31 @args = split(/:/,$_,99);
32 $ans = pop(@args);
33 $try = "$f('" . join("','", @args) . "');";
34 if (($ans1 = eval($try)) eq $ans) {
35 print "ok $test\n";
36 } else {
37 print "not ok $test\n";
38 print "# '$try' expected: '$ans' got: '$ans1'\n";
39 }
40 }
41}
42__END__
43&fnorm
44abc:NaN
45 1 a:NaN
461bcd2:NaN
4711111b:NaN
48+1z:NaN
49-1z:NaN
500:+0E+0
51+0:+0E+0
52+00:+0E+0
53+0 0 0:+0E+0
54000000 0000000 00000:+0E+0
55-0:+0E+0
56-0000:+0E+0
57+1:+1E+0
58+01:+1E+0
59+001:+1E+0
60+00000100000:+1E+5
61123456789:+123456789E+0
62-1:-1E+0
63-01:-1E+0
64-001:-1E+0
65-123456789:-123456789E+0
66-00000100000:-1E+5
67123.456a:NaN
68123.456:+123456E-3
690.01:+1E-2
70.002:+2E-3
71-0.0003:-3E-4
72-.0000000004:-4E-10
73123456E2:+123456E+2
74123456E-2:+123456E-2
75-123456E2:-123456E+2
76-123456E-2:-123456E-2
771e1:+1E+1
782e-11:+2E-11
79-3e111:-3E+111
80-4e-1111:-4E-1111
81&fneg
82abd:NaN
83+0:+0E+0
84+1:-1E+0
85-1:+1E+0
86+123456789:-123456789E+0
87-123456789:+123456789E+0
88+123.456789:-123456789E-6
89-123456.789:+123456789E-3
90&fabs
91abc:NaN
92+0:+0E+0
93+1:+1E+0
94-1:+1E+0
95+123456789:+123456789E+0
96-123456789:+123456789E+0
97+123.456789:+123456789E-6
98-123456.789:+123456789E-3
99&fround
100$bigfloat::rnd_mode = 'trunc'
101+10123456789:5:+10123E+6
102-10123456789:5:-10123E+6
103+10123456789:9:+101234567E+2
104-10123456789:9:-101234567E+2
105+101234500:6:+101234E+3
106-101234500:6:-101234E+3
107$bigfloat::rnd_mode = 'zero'
108+20123456789:5:+20123E+6
109-20123456789:5:-20123E+6
110+20123456789:9:+201234568E+2
111-20123456789:9:-201234568E+2
112+201234500:6:+201234E+3
113-201234500:6:-201234E+3
114$bigfloat::rnd_mode = '+inf'
115+30123456789:5:+30123E+6
116-30123456789:5:-30123E+6
117+30123456789:9:+301234568E+2
118-30123456789:9:-301234568E+2
119+301234500:6:+301235E+3
120-301234500:6:-301234E+3
121$bigfloat::rnd_mode = '-inf'
122+40123456789:5:+40123E+6
123-40123456789:5:-40123E+6
124+40123456789:9:+401234568E+2
125-40123456789:9:-401234568E+2
126+401234500:6:+401234E+3
127-401234500:6:-401235E+3
128$bigfloat::rnd_mode = 'odd'
129+50123456789:5:+50123E+6
130-50123456789:5:-50123E+6
131+50123456789:9:+501234568E+2
132-50123456789:9:-501234568E+2
133+501234500:6:+501235E+3
134-501234500:6:-501235E+3
135$bigfloat::rnd_mode = 'even'
136+60123456789:5:+60123E+6
137-60123456789:5:-60123E+6
138+60123456789:9:+601234568E+2
139-60123456789:9:-601234568E+2
140+601234500:6:+601234E+3
141-601234500:6:-601234E+3
142&ffround
143$bigfloat::rnd_mode = 'trunc'
144+1.23:-1:+12E-1
145-1.23:-1:-12E-1
146+1.27:-1:+12E-1
147-1.27:-1:-12E-1
148+1.25:-1:+12E-1
149-1.25:-1:-12E-1
150+1.35:-1:+13E-1
151-1.35:-1:-13E-1
152-0.006:-1:+0E+0
153-0.006:-2:+0E+0
154$bigfloat::rnd_mode = 'zero'
155+2.23:-1:+22E-1
156-2.23:-1:-22E-1
157+2.27:-1:+23E-1
158-2.27:-1:-23E-1
159+2.25:-1:+22E-1
160-2.25:-1:-22E-1
161+2.35:-1:+23E-1
162-2.35:-1:-23E-1
163-0.0065:-1:+0E+0
164-0.0065:-2:-1E-2
165-0.0065:-3:-6E-3
166-0.0065:-4:-65E-4
167-0.0065:-5:-65E-4
168$bigfloat::rnd_mode = '+inf'
169+3.23:-1:+32E-1
170-3.23:-1:-32E-1
171+3.27:-1:+33E-1
172-3.27:-1:-33E-1
173+3.25:-1:+33E-1
174-3.25:-1:-32E-1
175+3.35:-1:+34E-1
176-3.35:-1:-33E-1
177-0.0065:-1:+0E+0
178-0.0065:-2:-1E-2
179-0.0065:-3:-6E-3
180-0.0065:-4:-65E-4
181-0.0065:-5:-65E-4
182$bigfloat::rnd_mode = '-inf'
183+4.23:-1:+42E-1
184-4.23:-1:-42E-1
185+4.27:-1:+43E-1
186-4.27:-1:-43E-1
187+4.25:-1:+42E-1
188-4.25:-1:-43E-1
189+4.35:-1:+43E-1
190-4.35:-1:-44E-1
191-0.0065:-1:+0E+0
192-0.0065:-2:-1E-2
193-0.0065:-3:-7E-3
194-0.0065:-4:-65E-4
195-0.0065:-5:-65E-4
196$bigfloat::rnd_mode = 'odd'
197+5.23:-1:+52E-1
198-5.23:-1:-52E-1
199+5.27:-1:+53E-1
200-5.27:-1:-53E-1
201+5.25:-1:+53E-1
202-5.25:-1:-53E-1
203+5.35:-1:+53E-1
204-5.35:-1:-53E-1
205-0.0065:-1:+0E+0
206-0.0065:-2:-1E-2
207-0.0065:-3:-7E-3
208-0.0065:-4:-65E-4
209-0.0065:-5:-65E-4
210$bigfloat::rnd_mode = 'even'
211+6.23:-1:+62E-1
212-6.23:-1:-62E-1
213+6.27:-1:+63E-1
214-6.27:-1:-63E-1
215+6.25:-1:+62E-1
216-6.25:-1:-62E-1
217+6.35:-1:+64E-1
218-6.35:-1:-64E-1
219-0.0065:-1:+0E+0
220-0.0065:-2:-1E-2
221-0.0065:-3:-6E-3
222-0.0065:-4:-65E-4
223-0.0065:-5:-65E-4
224&fcmp
225abc:abc:
226abc:+0:
227+0:abc:
228+0:+0:0
229-1:+0:-1
230+0:-1:1
231+1:+0:1
232+0:+1:-1
233-1:+1:-1
234+1:-1:1
235-1:-1:0
236+1:+1:0
237+123:+123:0
238+123:+12:1
239+12:+123:-1
240-123:-123:0
241-123:-12:-1
242-12:-123:1
243+123:+124:-1
244+124:+123:1
245-123:-124:1
246-124:-123:-1
247&fadd
248abc:abc:NaN
249abc:+0:NaN
250+0:abc:NaN
251+0:+0:+0E+0
252+1:+0:+1E+0
253+0:+1:+1E+0
254+1:+1:+2E+0
255-1:+0:-1E+0
256+0:-1:-1E+0
257-1:-1:-2E+0
258-1:+1:+0E+0
259+1:-1:+0E+0
260+9:+1:+1E+1
261+99:+1:+1E+2
262+999:+1:+1E+3
263+9999:+1:+1E+4
264+99999:+1:+1E+5
265+999999:+1:+1E+6
266+9999999:+1:+1E+7
267+99999999:+1:+1E+8
268+999999999:+1:+1E+9
269+9999999999:+1:+1E+10
270+99999999999:+1:+1E+11
271+10:-1:+9E+0
272+100:-1:+99E+0
273+1000:-1:+999E+0
274+10000:-1:+9999E+0
275+100000:-1:+99999E+0
276+1000000:-1:+999999E+0
277+10000000:-1:+9999999E+0
278+100000000:-1:+99999999E+0
279+1000000000:-1:+999999999E+0
280+10000000000:-1:+9999999999E+0
281+123456789:+987654321:+111111111E+1
282-123456789:+987654321:+864197532E+0
283-123456789:-987654321:-111111111E+1
284+123456789:-987654321:-864197532E+0
285&fsub
286abc:abc:NaN
287abc:+0:NaN
288+0:abc:NaN
289+0:+0:+0E+0
290+1:+0:+1E+0
291+0:+1:-1E+0
292+1:+1:+0E+0
293-1:+0:-1E+0
294+0:-1:+1E+0
295-1:-1:+0E+0
296-1:+1:-2E+0
297+1:-1:+2E+0
298+9:+1:+8E+0
299+99:+1:+98E+0
300+999:+1:+998E+0
301+9999:+1:+9998E+0
302+99999:+1:+99998E+0
303+999999:+1:+999998E+0
304+9999999:+1:+9999998E+0
305+99999999:+1:+99999998E+0
306+999999999:+1:+999999998E+0
307+9999999999:+1:+9999999998E+0
308+99999999999:+1:+99999999998E+0
309+10:-1:+11E+0
310+100:-1:+101E+0
311+1000:-1:+1001E+0
312+10000:-1:+10001E+0
313+100000:-1:+100001E+0
314+1000000:-1:+1000001E+0
315+10000000:-1:+10000001E+0
316+100000000:-1:+100000001E+0
317+1000000000:-1:+1000000001E+0
318+10000000000:-1:+10000000001E+0
319+123456789:+987654321:-864197532E+0
320-123456789:+987654321:-111111111E+1
321-123456789:-987654321:+864197532E+0
322+123456789:-987654321:+111111111E+1
323&fmul
324abc:abc:NaN
325abc:+0:NaN
326+0:abc:NaN
327+0:+0:+0E+0
328+0:+1:+0E+0
329+1:+0:+0E+0
330+0:-1:+0E+0
331-1:+0:+0E+0
332+123456789123456789:+0:+0E+0
333+0:+123456789123456789:+0E+0
334-1:-1:+1E+0
335-1:+1:-1E+0
336+1:-1:-1E+0
337+1:+1:+1E+0
338+2:+3:+6E+0
339-2:+3:-6E+0
340+2:-3:-6E+0
341-2:-3:+6E+0
342+111:+111:+12321E+0
343+10101:+10101:+102030201E+0
344+1001001:+1001001:+1002003002001E+0
345+100010001:+100010001:+10002000300020001E+0
346+10000100001:+10000100001:+100002000030000200001E+0
347+11111111111:+9:+99999999999E+0
348+22222222222:+9:+199999999998E+0
349+33333333333:+9:+299999999997E+0
350+44444444444:+9:+399999999996E+0
351+55555555555:+9:+499999999995E+0
352+66666666666:+9:+599999999994E+0
353+77777777777:+9:+699999999993E+0
354+88888888888:+9:+799999999992E+0
355+99999999999:+9:+899999999991E+0
356&fdiv
357abc:abc:NaN
358abc:+1:abc:NaN
359+1:abc:NaN
360+0:+0:NaN
361+0:+1:+0E+0
362+1:+0:NaN
363+0:-1:+0E+0
364-1:+0:NaN
365+1:+1:+1E+0
366-1:-1:+1E+0
367+1:-1:-1E+0
368-1:+1:-1E+0
369+1:+2:+5E-1
370+2:+1:+2E+0
371+10:+5:+2E+0
372+100:+4:+25E+0
373+1000:+8:+125E+0
374+10000:+16:+625E+0
375+10000:-16:-625E+0
376+999999999999:+9:+111111111111E+0
377+999999999999:+99:+10101010101E+0
378+999999999999:+999:+1001001001E+0
379+999999999999:+9999:+100010001E+0
380+999999999999999:+99999:+10000100001E+0
381+1000000000:+9:+1111111111111111111111111111111111111111E-31
382+2000000000:+9:+2222222222222222222222222222222222222222E-31
383+3000000000:+9:+3333333333333333333333333333333333333333E-31
384+4000000000:+9:+4444444444444444444444444444444444444444E-31
385+5000000000:+9:+5555555555555555555555555555555555555556E-31
386+6000000000:+9:+6666666666666666666666666666666666666667E-31
387+7000000000:+9:+7777777777777777777777777777777777777778E-31
388+8000000000:+9:+8888888888888888888888888888888888888889E-31
389+9000000000:+9:+1E+9
390+35500000:+113:+3141592920353982300884955752212389380531E-34
391+71000000:+226:+3141592920353982300884955752212389380531E-34
392+106500000:+339:+3141592920353982300884955752212389380531E-34
393+1000000000:+3:+3333333333333333333333333333333333333333E-31
394$bigfloat::div_scale = 20
395+1000000000:+9:+11111111111111111111E-11
396+2000000000:+9:+22222222222222222222E-11
397+3000000000:+9:+33333333333333333333E-11
398+4000000000:+9:+44444444444444444444E-11
399+5000000000:+9:+55555555555555555556E-11
400+6000000000:+9:+66666666666666666667E-11
401+7000000000:+9:+77777777777777777778E-11
402+8000000000:+9:+88888888888888888889E-11
403+9000000000:+9:+1E+9
404+35500000:+113:+314159292035398230088E-15
405+71000000:+226:+314159292035398230088E-15
406+106500000:+339:+31415929203539823009E-14
407+1000000000:+3:+33333333333333333333E-11
408$bigfloat::div_scale = 40
409&fsqrt
410+0:+0E+0
411-1:NaN
412-2:NaN
413-16:NaN
414-123.456:NaN
415+1:+1E+0
416+1.44:+12E-1
417+2:+141421356237309504880168872420969807857E-38
418+4:+2E+0
419+16:+4E+0
420+100:+1E+1
421+123.456:+1111107555549866648462149404118219234119E-38
422+15241.383936:+123456E-3