This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] Math::BigInt v1.87 take 5
[perl5.git] / lib / Math / BigInt / t / bigfltpm.t
1 #!/usr/bin/perl -w
2
3 use Test;
4 use strict;
5
6 BEGIN
7   {
8   $| = 1;
9   # to locate the testing files
10   my $location = $0; $location =~ s/bigfltpm.t//i;
11   if ($ENV{PERL_CORE})
12     {
13     # testing with the core distribution
14     @INC = qw(../lib);
15     }
16   unshift @INC, '../lib';
17   if (-d 't')
18     {
19     chdir 't';
20     require File::Spec;
21     unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
22     }
23   else
24     {
25     unshift @INC, $location;
26     }
27   print "# INC = @INC\n";
28
29   plan tests => 2064
30         + 5;            # own tests
31   }
32
33 use Math::BigInt lib => 'Calc';
34 use Math::BigFloat;
35
36 use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
37 $class = "Math::BigFloat";
38 $CL = "Math::BigInt::Calc";
39
40 ok ($class->config()->{class},$class);
41 ok ($class->config()->{with}, $CL);
42
43 # bug #17447: Can't call method Math::BigFloat->bsub, not a valid method
44 my $c = Math::BigFloat->new( '123.3' );
45 ok ($c->fsub(123) eq '0.3', 1); # calling fsub on a BigFloat works
46
47 # Bug until BigInt v1.86, the scale wasn't treated as a scalar:
48 $c = Math::BigFloat->new('0.008'); my $d = Math::BigFloat->new(3);
49 my $e = $c->bdiv(Math::BigFloat->new(3),$d);
50
51 ok ($e,'0.00267'); # '0.008 / 3 => 0.0027');
52 ok (ref($e->{_e}->[0]), ''); # 'Not a BigInt');
53
54 require 'bigfltpm.inc'; # all tests here for sharing