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