1# -*- mode: perl; -*- 2 3# test the "l", "lib", "try" and "only" options: 4 5use strict; 6use warnings; 7 8use Test::More tests => 14; 9 10use bigfloat; 11 12# Catch warning. 13 14my $warning; 15local $SIG{__WARN__} = sub { 16 $warning = $_[0]; 17}; 18 19my $rc; 20 21$warning = ""; 22$rc = eval { bigfloat->import("l" => "foo") }; 23subtest qq|eval { bigfloat->import("l" => "foo") }| => sub { 24 plan tests => 2; 25 26 is($@, '', "didn't die"); 27 is($warning, "", "didn't get a warning"); 28}; 29 30$warning = ""; 31$rc = eval { bigfloat->import("lib" => "foo") }; 32subtest qq|eval { bigfloat->import("lib" => "foo") }| => sub { 33 plan tests => 2; 34 35 is($@, '', "didn't die"); 36 is($warning, "", "didn't get a warning"); 37}; 38 39$warning = ""; 40$rc = eval { bigfloat->import("try" => "foo") }; 41subtest qq|eval { bigfloat->import("try" => "foo") }| => sub { 42 plan tests => 2; 43 44 is($@, '', "didn't die"); 45 is($warning, "", "didn't get a warning"); 46}; 47 48$warning = ""; 49$rc = eval { bigfloat->import("only" => "foo") }; 50subtest qq|eval { bigfloat->import("only" => "foo") }| => sub { 51 plan tests => 2; 52 53 is($@, '', "didn't die"); 54 is($warning, "", "didn't get a warning"); 55}; 56 57$warning = ""; 58$rc = eval { bigfloat->import("foo" => "bar") }; 59subtest qq|eval { bigfloat->import("foo" => "bar") }| => sub { 60 plan tests => 2; 61 62 is($@, '', "didn't die"); 63 is($warning, "", "didn't get a warning"); 64}; 65 66# test that options are only lowercase (don't see a reason why allow UPPER) 67 68foreach (qw/L LIB Lib T Trace TRACE V Version VERSION/) { 69 $rc = eval { bigfloat->import($_ => "bar") }; 70 like($@, qr/^Unknown option /i, 71 qq|eval { bigfloat->import($_ => "bar") }|); 72} 73