Merge bignum 0.10, from Tels.
[p5sagit/p5-mst-13.2.git] / lib / bignum / t / bigrat.t
CommitLineData
126f3c5f 1#!/usr/bin/perl -w
2
3###############################################################################
4
5use Test;
6use strict;
7
8BEGIN
9 {
10 $| = 1;
11 chdir 't' if -d 't';
12 unshift @INC, '../lib';
13 plan tests => 4;
14 }
15
16use bigrat;
17
18###############################################################################
19# general tests
20
21my $x = 5; ok (ref($x),'Math::BigInt'); # :constant
22
23# todo: ok (2 + 2.5,4.5); # should still work
24# todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat');
25
26$x = 2 ** 255; ok (ref($x),'Math::BigInt');
27
28# see if Math::BigRat constant works
29ok (1/3, '1/3');
30ok (1/4+1/3,'7/12');
31
32###############################################################################
33# accurarcy and precision
34
35# this might change!
36#ok_undef ($Math::BigInt::accuracy);
37#ok_undef ($Math::BigInt::precision);
38#ok_undef ($Math::BigFloat::accuracy);
39#ok_undef ($Math::BigFloat::precision);
40#bigrat->accuracy(5);
41#ok ($Math::BigInt::accuracy,5);
42#ok ($Math::BigFloat::accuracy,5);
43#bigrat->precision(-2);
44#ok_undef ($Math::BigInt::accuracy);
45#ok_undef ($Math::BigFloat::accuracy);
46#ok ($Math::BigInt::precision,-2);
47#ok ($Math::BigFloat::precision,-2);
48
49###############################################################################
50###############################################################################
51# Perl 5.005 does not like ok ($x,undef)
52
53sub ok_undef
54 {
55 my $x = shift;
56
57 ok (1,1) and return if !defined $x;
58 ok ($x,'undef');
59 }