#!/usr/bin/perl -w
BEGIN
{
$| = 1;
my
$location
= $0;
$location
=~ s/mbimbf.t//i;
if
(
$ENV
{PERL_CORE})
{
@INC
=
qw(../lib)
;
}
else
{
unshift
@INC
,
'../lib'
;
}
if
(-d
't'
)
{
chdir
't'
;
unshift
@INC
, File::Spec->catdir(File::Spec->updir,
$location
);
}
else
{
unshift
@INC
,
$location
;
}
print
"# INC = @INC\n"
;
plan
tests
=> 684
+ 23;
}
$mbi
=
'Math::BigInt'
;
$mbf
=
'Math::BigFloat'
;
require
'mbimbf.inc'
;
Math::BigInt->round_mode(
'even'
);
Math::BigFloat->round_mode(
'even'
);
ok (
$Math::BigInt::rnd_mode
,
'even'
);
ok (
$Math::BigFloat::rnd_mode
,
'even'
);
my
$x
=
eval
'$mbi->round_mode("huhmbi");'
;
print
"# Got '$@'\n"
unless
ok ($@ =~ /^Unknown round mode
'huhmbi'
at/);
$x
=
eval
'$mbf->round_mode("huhmbf");'
;
print
"# Got '$@'\n"
unless
ok ($@ =~ /^Unknown round mode
'huhmbf'
at/);
$x
=
eval
'$Math::BigInt::rnd_mode = "huhmbi";'
;
print
"# Got '$@'\n"
unless
ok ($@ =~ /^Unknown round mode
'huhmbi'
at/);
$x
=
eval
'$Math::BigFloat::rnd_mode = "huhmbf";'
;
print
"# Got '$@'\n"
unless
ok ($@ =~ /^Unknown round mode
'huhmbf'
at/);
$mbi
->round_mode(
'odd'
); ok (
$Math::BigInt::rnd_mode
,
'odd'
);
$mbf
->round_mode(
'odd'
); ok (
$Math::BigInt::rnd_mode
,
'odd'
);
foreach
my
$class
(
qw/Math::BigInt Math::BigFloat/
)
{
ok (
$class
->accuracy(5),5);
ok_undef (
$class
->precision());
ok (
$class
->precision(5),5);
ok_undef (
$class
->accuracy());
}
foreach
my
$class
(
qw/Math::BigInt Math::BigFloat/
)
{
$class
->accuracy(42);
my
$x
=
$class
->new(123);
ok (
$x
->accuracy(),42);
ok (
$x
->accuracy(
undef
),42);
ok (
$x
->accuracy(),42);
$class
->accuracy(
undef
);
$class
->precision(
undef
);
}
$x
= Math::BigFloat->new(100);
$x
=
$x
->blog(Math::BigInt->new(10));
ok (
$x
,2);