Commit | Line | Data |
126f3c5f |
1 | #!/usr/bin/perl -w |
2 | |
48441d71 |
3 | # test the "l", "lib", "try" and "only" options: |
4 | |
b68b7ab1 |
5 | use Test::More; |
126f3c5f |
6 | use strict; |
7 | |
8 | BEGIN |
9 | { |
10 | $| = 1; |
11 | chdir 't' if -d 't'; |
12 | unshift @INC, '../lib'; |
48441d71 |
13 | plan tests => 19; |
126f3c5f |
14 | } |
15 | |
16 | use bignum; |
17 | |
48441d71 |
18 | my @W; |
19 | { |
20 | # catch warnings: |
21 | require Carp; |
22 | no warnings 'redefine'; |
23 | *Carp::carp = sub { push @W, $_[0]; }; |
24 | } |
25 | |
126f3c5f |
26 | my $rc = eval ('bignum->import( "l" => "foo" );'); |
b68b7ab1 |
27 | is ($@,''); # shouldn't die |
48441d71 |
28 | is (scalar @W, 1, 'one warning'); |
29 | like ($W[0], qr/fallback to Math::/, 'got fallback'); |
30 | |
126f3c5f |
31 | $rc = eval ('bignum->import( "lib" => "foo" );'); |
b68b7ab1 |
32 | is ($@,''); # ditto |
48441d71 |
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 |
126f3c5f |
40 | |
41 | $rc = eval ('bignum->import( "foo" => "bar" );'); |
b68b7ab1 |
42 | like ($@, qr/^Unknown option foo/i, 'died'); # should die |
126f3c5f |
43 | |
48441d71 |
44 | $rc = eval ('bignum->import( "only" => "bar" );'); |
45 | like ($@, qr/fallback disallowed/i, 'died'); # should die |
46 | |
126f3c5f |
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" );'); |
b68b7ab1 |
52 | like ($@, qr/^Unknown option $_/i, 'died'); # should die |
126f3c5f |
53 | } |
54 | |