[PATCH9 BigInt v1.60 fix for "\n"
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / downgrade.t
CommitLineData
e77e1900 1#!/usr/bin/perl -w
2
3use Test;
4use strict;
5
6BEGIN
7 {
8 $| = 1;
9 unshift @INC, '../lib'; # for running manually
9393ace2 10 my $location = $0; $location =~ s/downgrade.t//;
e77e1900 11 unshift @INC, $location; # to locate the testing files
12 chdir 't' if -d 't';
9393ace2 13 plan tests => 12;
e77e1900 14 }
15
9393ace2 16use Math::BigInt upgrade => 'Math::BigFloat';
e77e1900 17use Math::BigFloat downgrade => 'Math::BigInt', upgrade => 'Math::BigInt';
18
19use 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
26ok (Math::BigFloat->downgrade(),'Math::BigInt');
27ok (Math::BigFloat->upgrade(),'Math::BigInt');
28
29# these downgrade
30ok (ref(Math::BigFloat->new('inf')),'Math::BigInt');
31ok (ref(Math::BigFloat->new('-inf')),'Math::BigInt');
32ok (ref(Math::BigFloat->new('NaN')),'Math::BigInt');
33ok (ref(Math::BigFloat->new('0')),'Math::BigInt');
34ok (ref(Math::BigFloat->new('1')),'Math::BigInt');
35ok (ref(Math::BigFloat->new('10')),'Math::BigInt');
36ok (ref(Math::BigFloat->new('-10')),'Math::BigInt');
37ok (ref(Math::BigFloat->new('-10.0E1')),'Math::BigInt');
38
9393ace2 39# disable, otherwise it screws calculations
40Math::BigFloat->upgrade(undef);
41ok (Math::BigFloat->upgrade()||'','');
42
43Math::BigFloat->div_scale(20); # make it a bit faster
44my $x = Math::BigFloat->new(2); # downgrades
45# the following test upgrade for bsqrt() and also makes new() NOT downgrade
46# for the bpow() side
47ok (Math::BigFloat->bpow('2','0.5'),$x->bsqrt());
48
e77e1900 49#require 'upgrade.inc'; # all tests here for sharing