1 #include this file into another test for subclass testing...
3 ok ($class->config()->{lib},$CL);
8 $_ =~ s/#.*$//; # remove comments
9 $_ =~ s/\s+$//; # trailing spaces
10 next if /^$/; # skip empty lines & comments
17 $setup = $_; $setup =~ s/\$/\$${class}::/g; # round_mode, div_scale
18 #print "\$setup== $setup\n";
25 @args = split(/:/,$1,99);
29 @args = split(/:/,$_,99); $ans = pop(@args);
31 $try = "\$x = new $class \"$args[0]\";";
35 } elsif ($f eq "finf") {
36 $try .= "\$x->binf('$args[1]');";
37 } elsif ($f eq "is_inf") {
38 $try .= "\$x->is_inf('$args[1]');";
39 } elsif ($f eq "fone") {
40 $try .= "\$x->bone('$args[1]');";
41 } elsif ($f eq "fstr") {
42 $try .= "\$x->accuracy($args[1]); \$x->precision($args[2]);";
43 $try .= '$x->bstr();';
44 } elsif ($f eq "parts") {
45 # ->bstr() to see if an object is returned
46 $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();';
48 } elsif ($f eq "numerator") {
49 # ->bstr() to see if an object is returned
50 $try .= '$x->numerator()->bstr();';
51 } elsif ($f eq "denominator") {
52 # ->bstr() to see if an object is returned
53 $try .= '$x->denominator()->bstr();';
54 } elsif ($f eq "numify") {
55 $try .= "\$x->numify();";
56 } elsif ($f eq "length") {
57 $try .= "\$x->length();";
58 # some unary ops (test the fxxx form, since that is done by AUTOLOAD)
59 } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|abs)$/) {
60 $try .= "\$x->b$1();";
61 # some is_xxx test function
62 } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan|int)$/) {
64 } elsif ($f eq "as_number") {
65 $try .= '$x->as_number();';
66 } elsif ($f eq "finc") {
68 } elsif ($f eq "fdec") {
70 }elsif ($f eq "fround") {
71 $try .= "$setup; \$x->bround($args[1]);";
72 } elsif ($f eq "ffround") {
73 $try .= "$setup; \$x->bfround($args[1]);";
74 } elsif ($f eq "fsqrt") {
75 $try .= "$setup; \$x->bsqrt();";
76 } elsif ($f eq "flog") {
77 $try .= "$setup; \$x->blog();";
78 } elsif ($f eq "ffac") {
79 $try .= "$setup; \$x->bfac();";
83 $try .= "\$y = new $class \"$args[1]\";";
86 } elsif ($f eq "facmp") {
87 $try .= '$x->bacmp($y);';
88 } elsif ($f eq "bpow") {
90 } elsif ($f eq "fpow") {
91 $try .= '$x->bpow($y);';
92 } elsif ($f eq "badd") {
94 } elsif ($f eq "bsub") {
96 } elsif ($f eq "bmul") {
98 } elsif ($f eq "bdiv") {
99 $try .= "$setup; \$x / \$y;";
100 } elsif ($f eq "fdiv-list") {
101 $try .= "$setup; join(',',\$x->bdiv(\$y));";
102 } elsif ($f eq "brsft") {
104 } elsif ($f eq "blsft") {
106 } elsif ($f eq "bmod") {
108 } else { warn "Unknown op '$f'"; }
110 # print "# Trying: '$try'\n";
112 if ($ans =~ m|^/(.*)$|)
121 print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0);
132 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
133 # if (ref($ans1) eq "$class")
135 # # float numbers are normalized (for now), so mantissa shouldn't have
137 # #print $ans1->_trailing_zeros(),"\n";
138 # print "# Has trailing zeros after '$try'\n"
139 # if !ok ($ans1->{_m}->_trailing_zeros(), 0);
142 } # end pattern or string
146 # check whether $class->new( Math::BigInt->new()) destroys it
147 # ($y == 12 in this case)
148 $x = Math::BigInt->new(1200); $y = $class->new($x);
149 ok ($y,1200); ok ($x,1200);
151 ###############################################################################
154 $x = $class->new(2); $x->bzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
155 $x = $class->new(2); $x->binf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
156 $x = $class->new(2); $x->bone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
157 $x = $class->new(2); $x->bnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
161 ###############################################################################
162 # Perl 5.005 does not like ok ($x,undef)
168 ok (1,1) and return if !defined $x;
212 -123.4567:-1234567/10000
236 000000_0000000_00000:0
247 -123456789:-123456789
255 -.0000000004:-1/2500000000
276 +123456789:-123456789
278 +123.456789:-123456789/1000000
279 -123456.789:123456789/1000
289 +123.456789:123456789/1000000
290 -123456.789:123456789/1000
319 +99999999:+1:100000000
320 +999999999:+1:1000000000
321 +9999999999:+1:10000000000
322 +99999999999:+1:100000000000
330 +100000000:-1:99999999
331 +1000000000:-1:999999999
332 +10000000000:-1:9999999999
333 +123456789:+987654321:1111111110
334 -123456789:+987654321:864197532
335 -123456789:-987654321:-1111111110
336 +123456789:-987654321:-864197532
367 +99999999:+1:99999998
368 +999999999:+1:999999998
369 +9999999999:+1:9999999998
370 +99999999999:+1:99999999998
377 +10000000:-1:10000001
378 +100000000:-1:100000001
379 +1000000000:-1:1000000001
380 +10000000000:-1:10000000001
381 +123456789:+987654321:-864197532
382 -123456789:+987654321:-1111111110
383 -123456789:-987654321:864197532
384 +123456789:-987654321:1111111110
414 +123456789123456789:+0:0
415 +0:+123456789123456789:0
425 +10101:+10101:102030201
426 +1001001:+1001001:1002003002001
427 +100010001:+100010001:10002000300020001
428 +10000100001:+10000100001:100002000030000200001
429 +11111111111:+9:99999999999
430 +22222222222:+9:199999999998
431 +33333333333:+9:299999999997
432 +44444444444:+9:399999999996
433 +55555555555:+9:499999999995
434 +66666666666:+9:599999999994
435 +77777777777:+9:699999999993
436 +88888888888:+9:799999999992
437 +99999999999:+9:899999999991
442 $div_scale = 40; $round_mode = 'even'
468 +999999999999:+9:111111111111
469 +999999999999:+99:10101010101
470 +999999999999:+999:1001001001
471 +999999999999:+9999:100010001
472 +999999999999999:+99999:10000100001
473 +1000000000:+9:1000000000/9
474 +2000000000:+9:2000000000/9
475 +3000000000:+9:1000000000/3
476 +4000000000:+9:4000000000/9
477 +5000000000:+9:5000000000/9
478 +6000000000:+9:2000000000/3
479 +7000000000:+9:7000000000/9
480 +8000000000:+9:8000000000/9
481 +9000000000:+9:1000000000
482 +35500000:+113:35500000/113
483 +71000000:+226:35500000/113
484 +106500000:+339:35500000/113
485 +1000000000:+3:1000000000/3
486 2:25.024996000799840031993601279744051189762:1000000000000000000000000000000000000000/12512498000399920015996800639872025594881
489 # reset scale for further tests
507 # it must be exactly /^[+-]inf$/
607 #12345678901234567890:20
678 # bpow test for overload of **