X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExporter.t;h=d2a9289c61c54d9877c8b1d3bf24208a7d27ffe7;hb=94efb9fbd94b706aee3772444ecd87b768a706d9;hp=f2771db3f530c7cad054db462cc7d4aa3020e1e7;hpb=9ebf09bc35992a0eeace2e06916ca4dca399c8f2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Exporter.t b/lib/Exporter.t index f2771db..d2a9289 100644 --- a/lib/Exporter.t +++ b/lib/Exporter.t @@ -21,7 +21,7 @@ sub ok ($;$) { } -print "1..19\n"; +print "1..24\n"; require Exporter; ok( 1, 'Exporter compiled' ); @@ -50,7 +50,7 @@ foreach my $meth (@::Exporter_Methods) { That => [qw(Above the @wailing)], tray => [qw(Fasten $seatbelt)], ); -@EXPORT = qw(lifejacket); +@EXPORT = qw(lifejacket is); @EXPORT_OK = qw(under &your $seat); $VERSION = '1.05'; @@ -72,6 +72,8 @@ $seat = 'seat'; @wailing = qw(AHHHHHH); %left = ( left => "right" ); +BEGIN {*is = \&Is}; +sub Is { 'Is' }; Exporter::export_ok_tags; @@ -89,6 +91,24 @@ Testing->import; ::ok( defined &lifejacket, 'simple import' ); +my $got = eval {&lifejacket}; +::ok ( $@ eq "", 'check we can call the imported subroutine') + or print STDERR "# \$\@ is $@\n"; +::ok ( $got eq 'lifejacket', 'and that it gave the correct result') + or print STDERR "# expected 'lifejacket', got " . + (defined $got ? "'$got'" : "undef") . "\n"; + +# The string eval is important. It stops $Foo::{is} existing when +# Testing->import is called. +::ok( eval "defined &is", + "Import a subroutine where exporter must create the typeglob" ); +my $got = eval "&is"; +::ok ( $@ eq "", 'check we can call the imported autoloaded subroutine') + or chomp ($@), print STDERR "# \$\@ is $@\n"; +::ok ( $got eq 'Is', 'and that it gave the correct result') + or print STDERR "# expected 'Is', got " . + (defined $got ? "'$got'" : "undef") . "\n"; + package Bar; my @imports = qw($seatbelt &Above stuff @wailing %left);