Commit | Line | Data |
b3abae2a |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use Test; |
5 | |
6 | BEGIN |
7 | { |
8 | $| = 1; |
091c87b1 |
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 | |
56b9c951 |
29 | plan tests => 7; |
b3abae2a |
30 | } |
31 | |
32 | use Math::BigInt ':constant'; |
33 | |
34 | ok (2 ** 255,'57896044618658097711785492504343953926634992332820282019728792003956564819968'); |
35 | |
56b9c951 |
36 | { |
2ab5f49d |
37 | no warnings 'portable'; # protect against "non-portable" warnings |
8f675a64 |
38 | # hexadecimal constants |
39 | ok (0x123456789012345678901234567890, |
40 | Math::BigInt->new('0x123456789012345678901234567890')); |
41 | # binary constants |
42 | ok (0b01010100011001010110110001110011010010010110000101101101, |
43 | Math::BigInt->new( |
56b9c951 |
44 | '0b01010100011001010110110001110011010010010110000101101101')); |
45 | } |
46 | |
b3abae2a |
47 | use Math::BigFloat ':constant'; |
48 | ok (1.0 / 3.0, '0.3333333333333333333333333333333333333333'); |
49 | |
50 | # stress-test Math::BigFloat->import() |
51 | |
52 | Math::BigFloat->import( qw/:constant/ ); |
53 | ok (1,1); |
54 | |
55 | Math::BigFloat->import( qw/:constant upgrade Math::BigRat/ ); |
56 | ok (1,1); |
57 | |
58 | Math::BigFloat->import( qw/upgrade Math::BigRat :constant/ ); |
59 | ok (1,1); |
60 | |
61 | # all tests done |
62 | |