1N/A#!/usr/bin/perl -w
1N/A
1N/Ause Test;
1N/Ause strict;
1N/A
1N/ABEGIN
1N/A {
1N/A $| = 1;
1N/A unshift @INC, '../lib'; # for running manually
1N/A my $location = $0; $location =~ s/downgrade.t//;
1N/A unshift @INC, $location; # to locate the testing files
1N/A chdir 't' if -d 't';
1N/A plan tests => 15;
1N/A }
1N/A
1N/Ause Math::BigInt upgrade => 'Math::BigFloat';
1N/Ause Math::BigFloat downgrade => 'Math::BigInt', upgrade => 'Math::BigInt';
1N/A
1N/Ause vars qw ($scale $class $try $x $y $f @args $ans $ans1 $ans1_str $setup
1N/A $ECL $CL);
1N/A$class = "Math::BigInt";
1N/A$CL = "Math::BigInt::Calc";
1N/A$ECL = "Math::BigFloat";
1N/A
1N/A# simplistic test for now
1N/Aok (Math::BigFloat->downgrade(),'Math::BigInt');
1N/Aok (Math::BigFloat->upgrade(),'Math::BigInt');
1N/A
1N/A# these downgrade
1N/Aok (ref(Math::BigFloat->new('inf')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('-inf')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('NaN')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('0')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('1')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('10')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('-10')),'Math::BigInt');
1N/Aok (ref(Math::BigFloat->new('-10.0E1')),'Math::BigInt');
1N/A
1N/A# bug until v1.67:
1N/Aok (Math::BigFloat->new('0.2E0'), '0.2');
1N/Aok (Math::BigFloat->new('0.2E1'), '2');
1N/A# until v1.67 resulted in 200:
1N/Aok (Math::BigFloat->new('0.2E2'), '20');
1N/A
1N/A# disable, otherwise it screws calculations
1N/AMath::BigFloat->upgrade(undef);
1N/Aok (Math::BigFloat->upgrade()||'','');
1N/A
1N/AMath::BigFloat->div_scale(20); # make it a bit faster
1N/Amy $x = Math::BigFloat->new(2); # downgrades
1N/A# the following test upgrade for bsqrt() and also makes new() NOT downgrade
1N/A# for the bpow() side
1N/Aok (Math::BigFloat->bpow('2','0.5'),$x->bsqrt());
1N/A
1N/A#require 'upgrade.inc'; # all tests here for sharing