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 "badd") {
92 } elsif ($f eq "bsub") {
94 } elsif ($f eq "bmul") {
96 } elsif ($f eq "bdiv") {
97 $try .= "$setup; \$x / \$y;";
98 } elsif ($f eq "fdiv-list") {
99 $try .= "$setup; join(',',\$x->bdiv(\$y));";
100 } elsif ($f eq "brsft") {
102 } elsif ($f eq "blsft") {
104 } elsif ($f eq "bmod") {
106 } else { warn "Unknown op '$f'"; }
108 # print "# Trying: '$try'\n";
110 if ($ans =~ m|^/(.*)$|)
119 print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0);
130 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
131 # if (ref($ans1) eq "$class")
133 # # float numbers are normalized (for now), so mantissa shouldn't have
135 # #print $ans1->_trailing_zeros(),"\n";
136 # print "# Has trailing zeros after '$try'\n"
137 # if !ok ($ans1->{_m}->_trailing_zeros(), 0);
140 } # end pattern or string
144 # check whether $class->new( Math::BigInt->new()) destroys it
145 # ($y == 12 in this case)
146 $x = Math::BigInt->new(1200); $y = $class->new($x);
147 ok ($y,1200); ok ($x,1200);
149 ###############################################################################
152 $x = $class->new(2); $x->bzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
153 $x = $class->new(2); $x->binf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
154 $x = $class->new(2); $x->bone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
155 $x = $class->new(2); $x->bnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
159 ###############################################################################
160 # Perl 5.005 does not like ok ($x,undef)
166 ok (1,1) and return if !defined $x;
210 -123.4567:-1234567/10000
234 000000_0000000_00000:0
245 -123456789:-123456789
253 -.0000000004:-1/2500000000
274 +123456789:-123456789
276 +123.456789:-123456789/1000000
277 -123456.789:123456789/1000
287 +123.456789:123456789/1000000
288 -123456.789:123456789/1000
317 +99999999:+1:100000000
318 +999999999:+1:1000000000
319 +9999999999:+1:10000000000
320 +99999999999:+1:100000000000
328 +100000000:-1:99999999
329 +1000000000:-1:999999999
330 +10000000000:-1:9999999999
331 +123456789:+987654321:1111111110
332 -123456789:+987654321:864197532
333 -123456789:-987654321:-1111111110
334 +123456789:-987654321:-864197532
365 +99999999:+1:99999998
366 +999999999:+1:999999998
367 +9999999999:+1:9999999998
368 +99999999999:+1:99999999998
375 +10000000:-1:10000001
376 +100000000:-1:100000001
377 +1000000000:-1:1000000001
378 +10000000000:-1:10000000001
379 +123456789:+987654321:-864197532
380 -123456789:+987654321:-1111111110
381 -123456789:-987654321:864197532
382 +123456789:-987654321:1111111110
412 +123456789123456789:+0:0
413 +0:+123456789123456789:0
423 +10101:+10101:102030201
424 +1001001:+1001001:1002003002001
425 +100010001:+100010001:10002000300020001
426 +10000100001:+10000100001:100002000030000200001
427 +11111111111:+9:99999999999
428 +22222222222:+9:199999999998
429 +33333333333:+9:299999999997
430 +44444444444:+9:399999999996
431 +55555555555:+9:499999999995
432 +66666666666:+9:599999999994
433 +77777777777:+9:699999999993
434 +88888888888:+9:799999999992
435 +99999999999:+9:899999999991
440 $div_scale = 40; $round_mode = 'even'
466 +999999999999:+9:111111111111
467 +999999999999:+99:10101010101
468 +999999999999:+999:1001001001
469 +999999999999:+9999:100010001
470 +999999999999999:+99999:10000100001
471 +1000000000:+9:1000000000/9
472 +2000000000:+9:2000000000/9
473 +3000000000:+9:1000000000/3
474 +4000000000:+9:4000000000/9
475 +5000000000:+9:5000000000/9
476 +6000000000:+9:2000000000/3
477 +7000000000:+9:7000000000/9
478 +8000000000:+9:8000000000/9
479 +9000000000:+9:1000000000
480 +35500000:+113:35500000/113
481 +71000000:+226:35500000/113
482 +106500000:+339:35500000/113
483 +1000000000:+3:1000000000/3
484 2:25.024996000799840031993601279744051189762:1000000000000000000000000000000000000000/12512498000399920015996800639872025594881
487 # reset scale for further tests
505 # it must be exactly /^[+-]inf$/
603 #12345678901234567890:20