#!/usr/bin/perl -w
BEGIN
{
$| = 1;
my
$location
= $0;
$location
=~ s/bigroot.t//i;
if
(
$ENV
{PERL_CORE})
{
@INC
=
qw(../lib)
;
}
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
=> 4 * 2;
}
my
$cl
=
"Math::BigFloat"
;
my
$c
=
"Math::BigInt"
;
test_broot (
'2'
,
'120'
, 8,
undef
,
'32768'
);
test_broot (
'2'
,
'60'
, 8,
undef
,
'181.0193359837561662466161566988413540569'
);
test_broot (
'2'
,
'60'
, 9,
undef
,
'101.5936673259647663841091609134277286651'
);
test_broot (
'2'
,
'60'
, 17,
undef
,
'11.54672461623965153271017217302844672562'
);
sub
test_broot
{
my
(
$x
,
$n
,
$y
,
$scale
,
$result
) =
@_
;
my
$s
=
$scale
||
'undef'
;
is (
$cl
->new(
$x
)->bpow(
$n
)->broot(
$y
,
$scale
),
$result
,
"Try: $cl $x->bpow($n)->broot($y,$s) == $result"
);
$result
=~ s/\..*//;
is (
$c
->new(
$x
)->bpow(
$n
)->broot(
$y
,
$scale
),
$result
,
"Try: $c $x->bpow($n)->broot($y,$s) == $result"
);
}