This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
blead is upstream for Math-BigInt-FastCalc
[perl5.git] / cpan / 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 require Carp;
22 no warnings 'redefine';
23 *Carp::carp = sub { push @W, $_[0]; };
24 }
25
26 my $rc = eval ('bignum->import( "l" => "foo" );');
27 is ($@,'');                                             # shouldn't die
28 is (scalar @W, 1, 'one warning');
29 like ($W[0], qr/fallback to Math::/, 'got fallback');
30
31 $rc = eval ('bignum->import( "lib" => "foo" );');
32 is ($@,'');                                             # ditto
33 is (scalar @W, 2, 'two warnings');
34 like ($W[1], qr/fallback to Math::/, 'got fallback');
35
36 $rc = eval ('bignum->import( "try" => "foo" );');
37 is ($@,'');                                             # shouldn't die
38 $rc = eval ('bignum->import( "try" => "foo" );');
39 is ($@,'');                                             # ditto
40
41 $rc = eval ('bignum->import( "foo" => "bar" );');
42 like ($@, qr/^Unknown option foo/i, 'died');                    # should die
43
44 $rc = eval ('bignum->import( "only" => "bar" );');
45 like ($@, qr/fallback disallowed/i, 'died');                    # should die
46
47 # test that options are only lowercase (don't see a reason why allow UPPER)
48
49 foreach (qw/L LIB Lib T Trace TRACE V Version VERSION/)
50   {
51   $rc = eval ('bignum->import( "$_" => "bar" );');
52   like ($@, qr/^Unknown option $_/i, 'died');                   # should die
53   }
54