my
$class
;
BEGIN {
$class
=
'Math::BigInt'
; }
BEGIN { use_ok(
$class
); }
my
@data
;
my
$space
=
"\t\r\n "
;
while
(<DATA>) {
s/
s/\s+$//;
next
unless
length
;
my
(
$in0
,
$out0
) =
split
/:/;
push
@data
, [
$in0
,
$out0
],
[
$in0
.
$space
,
$out0
],
[
$space
.
$in0
,
$out0
],
[
$space
.
$in0
.
$space
,
$out0
];
}
for
my
$entry
(
@data
) {
my
(
$in0
,
$out0
) =
@$entry
;
{
my
$x
;
my
$test
=
qq|\$x = $class -> from_dec("$in0");|
;
eval
$test
;
die
$@
if
$@;
subtest
$test
,
sub
{
plan
tests
=> 2,
is(
ref
(
$x
),
$class
,
"output arg is a $class"
);
is(
$x
,
$out0
,
'output arg has the right value'
);
};
}
{
for
my
$str
(
"-1"
,
"0"
,
"1"
,
"-inf"
,
"+inf"
,
"NaN"
) {
my
$x
;
my
$test
=
qq|\$x = $class -> new("$str");|
.
qq| \$x -> from_dec("$in0");|
;
eval
$test
;
die
$@
if
$@;
subtest
$test
,
sub
{
plan
tests
=> 2,
is(
ref
(
$x
),
$class
,
"output arg is a $class"
);
is(
$x
,
$out0
,
'output arg has the right value'
);
};
}
}
}