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