Commit | Line | Data |
---|---|---|
e77e1900 JH |
1 | #!/usr/bin/perl -w |
2 | ||
3 | use Test; | |
4 | use strict; | |
5 | ||
6 | BEGIN | |
7 | { | |
8 | $| = 1; | |
9 | unshift @INC, '../lib'; # for running manually | |
9393ace2 | 10 | my $location = $0; $location =~ s/downgrade.t//; |
e77e1900 JH |
11 | unshift @INC, $location; # to locate the testing files |
12 | chdir 't' if -d 't'; | |
8df1e0a2 | 13 | plan tests => 15; |
e77e1900 JH |
14 | } |
15 | ||
9393ace2 | 16 | use Math::BigInt upgrade => 'Math::BigFloat'; |
e77e1900 JH |
17 | use Math::BigFloat downgrade => 'Math::BigInt', upgrade => 'Math::BigInt'; |
18 | ||
19 | use vars qw ($scale $class $try $x $y $f @args $ans $ans1 $ans1_str $setup | |
20 | $ECL $CL); | |
21 | $class = "Math::BigInt"; | |
22 | $CL = "Math::BigInt::Calc"; | |
23 | $ECL = "Math::BigFloat"; | |
24 | ||
25 | # simplistic test for now | |
26 | ok (Math::BigFloat->downgrade(),'Math::BigInt'); | |
27 | ok (Math::BigFloat->upgrade(),'Math::BigInt'); | |
28 | ||
29 | # these downgrade | |
30 | ok (ref(Math::BigFloat->new('inf')),'Math::BigInt'); | |
31 | ok (ref(Math::BigFloat->new('-inf')),'Math::BigInt'); | |
32 | ok (ref(Math::BigFloat->new('NaN')),'Math::BigInt'); | |
33 | ok (ref(Math::BigFloat->new('0')),'Math::BigInt'); | |
34 | ok (ref(Math::BigFloat->new('1')),'Math::BigInt'); | |
35 | ok (ref(Math::BigFloat->new('10')),'Math::BigInt'); | |
36 | ok (ref(Math::BigFloat->new('-10')),'Math::BigInt'); | |
37 | ok (ref(Math::BigFloat->new('-10.0E1')),'Math::BigInt'); | |
38 | ||
8df1e0a2 T |
39 | # bug until v1.67: |
40 | ok (Math::BigFloat->new('0.2E0'), '0.2'); | |
41 | ok (Math::BigFloat->new('0.2E1'), '2'); | |
42 | # until v1.67 resulted in 200: | |
43 | ok (Math::BigFloat->new('0.2E2'), '20'); | |
44 | ||
9393ace2 JH |
45 | # disable, otherwise it screws calculations |
46 | Math::BigFloat->upgrade(undef); | |
47 | ok (Math::BigFloat->upgrade()||'',''); | |
48 | ||
49 | Math::BigFloat->div_scale(20); # make it a bit faster | |
50 | my $x = Math::BigFloat->new(2); # downgrades | |
51 | # the following test upgrade for bsqrt() and also makes new() NOT downgrade | |
52 | # for the bpow() side | |
53 | ok (Math::BigFloat->bpow('2','0.5'),$x->bsqrt()); | |
54 | ||
e77e1900 | 55 | #require 'upgrade.inc'; # all tests here for sharing |