1#!/usr/bin/perl -w 2 3use strict; 4use Test; 5 6BEGIN 7 { 8 $| = 1; 9 # to locate the testing files 10 my $location = $0; $location =~ s/constant.t//i; 11 if ($ENV{PERL_CORE}) 12 { 13 # testing with the core distribution 14 @INC = qw(../t/lib); 15 } 16 unshift @INC, qw(../lib); 17 if (-d 't') 18 { 19 chdir 't'; 20 require File::Spec; 21 unshift @INC, File::Spec->catdir(File::Spec->updir, $location); 22 } 23 else 24 { 25 unshift @INC, $location; 26 } 27 print "# INC = @INC\n"; 28 29 plan tests => 7; 30 if ($] < 5.006) 31 { 32 for (1..7) { skip (1,'Not supported on older Perls'); } 33 exit; 34 } 35 } 36 37use Math::BigInt ':constant'; 38 39ok (2 ** 255,'57896044618658097711785492504343953926634992332820282019728792003956564819968'); 40 41{ 42 no warnings 'portable'; # protect against "non-portable" warnings 43# hexadecimal constants 44ok (0x123456789012345678901234567890, 45 Math::BigInt->new('0x123456789012345678901234567890')); 46# binary constants 47ok (0b01010100011001010110110001110011010010010110000101101101, 48 Math::BigInt->new( 49 '0b01010100011001010110110001110011010010010110000101101101')); 50} 51 52use Math::BigFloat ':constant'; 53ok (1.0 / 3.0, '0.3333333333333333333333333333333333333333'); 54 55# stress-test Math::BigFloat->import() 56 57Math::BigFloat->import( qw/:constant/ ); 58ok (1,1); 59 60Math::BigFloat->import( qw/:constant upgrade Math::BigRat/ ); 61ok (1,1); 62 63Math::BigFloat->import( qw/upgrade Math::BigRat :constant/ ); 64ok (1,1); 65 66# all tests done 67 68