Move Math::BigInt from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Math-BigInt / t / bigintpm.t
CommitLineData
58cde26e 1#!/usr/bin/perl -w
748a9306 2
58cde26e 3use Test;
abcfbf51 4use strict;
58cde26e 5
abcfbf51 6BEGIN
58cde26e 7 {
abcfbf51 8 $| = 1;
9 unshift @INC, '../lib'; # for running manually
10 my $location = $0; $location =~ s/bigintpm.t//;
11 unshift @INC, $location; # to locate the testing files
027dc388 12 chdir 't' if -d 't';
0dceeee6 13 plan tests => 3273 + 6;
58cde26e 14 }
15
233f7bc0 16use Math::BigInt lib => 'Calc';
58cde26e 17
394e6ffb 18use vars qw ($scale $class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
abcfbf51 19$class = "Math::BigInt";
394e6ffb 20$CL = "Math::BigInt::Calc";
58cde26e 21
7aa7e0ae 22#############################################################################
23# from_hex(), from_bin() and from_oct() tests
24
25my $x = Math::BigInt->from_hex('0xcafe');
26ok ($x, "51966", 'from_hex() works');
27
28$x = Math::BigInt->from_hex('0xcafebabedead');
29ok ($x, "223195403574957", 'from_hex() works with long numbers');
30
31$x = Math::BigInt->from_bin('0b1001');
32ok ($x, "9", 'from_bin() works');
33
34$x = Math::BigInt->from_bin('0b1001100110011001100110011001');
35ok ($x, "161061273", 'from_bin() works with big numbers');
36
37$x = Math::BigInt->from_oct('0775');
38ok ($x, "509", 'from_oct() works');
39
40$x = Math::BigInt->from_oct('07777777777777711111111222222222');
41ok ($x, "9903520314281112085086151826", 'from_oct() works with big numbers');
42
43#############################################################################
44# all the other tests
45
abcfbf51 46require 'bigintpm.inc'; # all tests here for sharing