Upgrage to bignum-0.21 and Math-BigRat-0.19
[p5sagit/p5-mst-13.2.git] / lib / bignum / t / option_l.t
1 #!/usr/bin/perl -w
2
3 # test the "l", "lib", "try" and "only" options:
4
5 use Test::More;
6 use strict;
7
8 BEGIN
9   {
10   $| = 1;
11   chdir 't' if -d 't';
12   unshift @INC, '../lib';
13   plan tests => 19;
14   }
15
16 use bignum;
17
18 my @W;
19 {
20 # catch warnings:
21 no warnings 'redefine';
22 *Carp::carp = sub { push @W, $_[0]; };
23 }
24
25 my $rc = eval ('bignum->import( "l" => "foo" );');
26 is ($@,'');                                             # shouldn't die
27 is (scalar @W, 1, 'one warning');
28 like ($W[0], qr/fallback to Math::/, 'got fallback');
29
30 $rc = eval ('bignum->import( "lib" => "foo" );');
31 is ($@,'');                                             # ditto
32 is (scalar @W, 2, 'two warnings');
33 like ($W[1], qr/fallback to Math::/, 'got fallback');
34
35 $rc = eval ('bignum->import( "try" => "foo" );');
36 is ($@,'');                                             # shouldn't die
37 $rc = eval ('bignum->import( "try" => "foo" );');
38 is ($@,'');                                             # ditto
39
40 $rc = eval ('bignum->import( "foo" => "bar" );');
41 like ($@, qr/^Unknown option foo/i, 'died');                    # should die
42
43 $rc = eval ('bignum->import( "only" => "bar" );');
44 like ($@, qr/fallback disallowed/i, 'died');                    # should die
45
46 # test that options are only lowercase (don't see a reason why allow UPPER)
47
48 foreach (qw/L LIB Lib T Trace TRACE V Version VERSION/)
49   {
50   $rc = eval ('bignum->import( "$_" => "bar" );');
51   like ($@, qr/^Unknown option $_/i, 'died');                   # should die
52   }
53