This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate perl
[perl5.git] / lib / Math / BigInt / t / constant.t
CommitLineData
b3abae2a
JH
1#!/usr/bin/perl -w
2
3use strict;
4use Test;
5
6BEGIN
7 {
8 $| = 1;
9 chdir 't' if -d 't';
10 unshift @INC, '../lib'; # for running manually
56b9c951 11 plan tests => 7;
3541f8c8
CN
12 if ($] < 5.006)
13 {
14 for (1..7) { skip (1,'Not supported on older Perls'); }
15 exit;
16 }
b3abae2a
JH
17 }
18
19use Math::BigInt ':constant';
20
21ok (2 ** 255,'57896044618658097711785492504343953926634992332820282019728792003956564819968');
22
56b9c951 23{
8f675a64
JH
24 no warnings 'portable';
25# hexadecimal constants
26ok (0x123456789012345678901234567890,
27 Math::BigInt->new('0x123456789012345678901234567890'));
28# binary constants
29ok (0b01010100011001010110110001110011010010010110000101101101,
30 Math::BigInt->new(
56b9c951
JH
31 '0b01010100011001010110110001110011010010010110000101101101'));
32}
33
b3abae2a
JH
34use Math::BigFloat ':constant';
35ok (1.0 / 3.0, '0.3333333333333333333333333333333333333333');
36
37# stress-test Math::BigFloat->import()
38
39Math::BigFloat->import( qw/:constant/ );
40ok (1,1);
41
42Math::BigFloat->import( qw/:constant upgrade Math::BigRat/ );
43ok (1,1);
44
45Math::BigFloat->import( qw/upgrade Math::BigRat :constant/ );
46ok (1,1);
47
48# all tests done
49