bigintc.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
use strict;
use Test;
{
$| = 1;
chdir 't' if -d 't';
}
print "# BASE_LEN = $BASE_LEN\n";
print "# MAX_VAL = $MAX_VAL\n";
print "# AND_BITS = $AND_BITS\n";
print "# XOR_BITS = $XOR_BITS\n";
print "# IOR_BITS = $OR_BITS\n";
# testing of Math::BigInt::Calc
my $C = 'Math::BigInt::Calc'; # pass classname to sub's
# _new and _str
###############################################################################
# _add, _sub, _mul, _div
###############################################################################
# and returns the same reference, not something new
###############################################################################
# is_zero, _is_one, _one, _zero
# _two() and _ten()
# is_odd, is_even
# _len
for (my $i = 1; $i < 9; $i++)
{
my $a = "$i" . '0' x ($i-1);
}
# _digit
# _copy
foreach (qw/ 1 12 123 1234 12345 123456 1234567 12345678 123456789/)
{
}
# _zeros
# _lsft, _rsft
# _acmp
# _modinv
# _div
# _num
foreach (qw/1 12 123 1234 12345 1234567 12345678 123456789 1234567890/)
{
}
# _sqrt
# _root
# _pow (and _root)
# 99 ** 2 = 9801, 999 ** 2 = 998001 etc
for my $i (2 .. 9)
{
if ($i <= 7)
{
}
}
##############################################################################
# _fac
# test that _fac modifes $x in place for small arguments
##############################################################################
# _inc and _dec
foreach (qw/1 11 121 1231 12341 1234561 12345671 123456781 1234567891/)
{
}
foreach (qw/19 119 1219 12319 1234519 12345619 123456719 1234567819/)
{
}
foreach (qw/999 9999 99999 9999999 99999999 999999999 9999999999 99999999999/)
{
}
my $BL;
{
}
# should not happen:
# $x = $C->_new("-2"); $y = $C->_new("4"); ok ($C->_acmp($x,$y),-1);
###############################################################################
# _mod
# _and, _or, _xor
# _from_hex, _from_bin
# _as_hex, _as_bin
# _check
###############################################################################
# __strip_zeros
{
# correct empty arrays
# don't strip single elements
# don't strip non-zero elements
$x = &{$C."::__strip_zeros"}([0,1]);
$x = &{$C."::__strip_zeros"}([0,1,2]);
# but strip leading zeros
$x = &{$C."::__strip_zeros"}([0,1,2,0]);
$x = &{$C."::__strip_zeros"}([0,1,2,0,0]);
$x = &{$C."::__strip_zeros"}([0,1,2,0,0,0]);
# collapse multiple zeros
$x = &{$C."::__strip_zeros"}([0,0,0,0]);
}
# done
1;