This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document string- and number-specific bitops in perlop
[perl5.git] / dist / Math-BigInt / t / bigintpm.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More tests => 3651 + 6;
5
6 use Math::BigInt lib => 'Calc';
7
8 use vars qw ($scale $class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
9 $class = "Math::BigInt";
10 $CL = "Math::BigInt::Calc";
11
12 #############################################################################
13 # from_hex(), from_bin() and from_oct() tests
14
15 my $x = Math::BigInt->from_hex('0xcafe');
16 is ($x, "51966", 'from_hex() works');
17  
18 $x = Math::BigInt->from_hex('0xcafebabedead');
19 is ($x, "223195403574957", 'from_hex() works with long numbers');
20  
21 $x = Math::BigInt->from_bin('0b1001');
22 is ($x, "9", 'from_bin() works');
23  
24 $x = Math::BigInt->from_bin('0b1001100110011001100110011001');
25 is ($x, "161061273", 'from_bin() works with big numbers');
26
27 $x = Math::BigInt->from_oct('0775');
28 is ($x, "509", 'from_oct() works');
29  
30 $x = Math::BigInt->from_oct('07777777777777711111111222222222');
31 is ($x, "9903520314281112085086151826", 'from_oct() works with big numbers');
32
33 #############################################################################
34 # all the other tests
35  
36 require 't/bigintpm.inc';       # all tests here for sharing