X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExporter.t;h=0e69cb194d1f5494795490c1bc0b779e37a351f5;hb=9ef2b94f54586a775e4e47eebd8bbd9e08ce5fdd;hp=1639cc11f3fc5caf73c3ab151698b2e32b56c73e;hpb=452617c3f7a5f3708b2a912420c39479d85cb7e5;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Exporter.t b/lib/Exporter.t index 1639cc1..0e69cb1 100644 --- a/lib/Exporter.t +++ b/lib/Exporter.t @@ -25,7 +25,7 @@ sub ok ($;$) { BEGIN { $test = 1; - print "1..28\n"; + print "1..30\n"; require Exporter; ok( 1, 'Exporter compiled' ); } @@ -119,17 +119,21 @@ package Bar; my @imports = qw($seatbelt &Above stuff @wailing %left); Testing->import(@imports); -::ok( (!grep { eval "!defined $_" } map({ /^\w/ ? "&$_" : $_ } @imports)), - 'import by symbols' ); +::ok( (! grep { my ($s, $n) = @$_; eval "\\$s$n != \\${s}Testing::$n" } + map { /^(\W)(\w+)/ ? [$1, $2] : ['&', $_] } + @imports), + 'import by symbols' ); package Yar; my @tags = qw(:This :tray); Testing->import(@tags); -::ok( (!grep { eval "!defined $_" } map { /^\w/ ? "&$_" : $_ } - map { @$_ } @{$Testing::EXPORT_TAGS{@tags}}), - 'import by tags' ); +::ok( (! grep { my ($s, $n) = @$_; eval "\\$s$n != \\${s}Testing::$n" } + map { /^(\W)(\w+)/ ? [$1, $2] : ['&', $_] } + map { @$_ } + @{$Testing::EXPORT_TAGS{@tags}}), + 'import by tags' ); package Arrr; @@ -141,17 +145,22 @@ Testing->import(qw(!lifejacket)); package Mars; Testing->import('/e/'); -::ok( (!grep { eval "!defined $_" } map { /^\w/ ? "&$_" : $_ } - grep { /e/ } @Testing::EXPORT, @Testing::EXPORT_OK), - 'import by regex'); +::ok( (! grep { my ($s, $n) = @$_; eval "\\$s$n != \\${s}Testing::$n" } + map { /^(\W)(\w+)/ ? [$1, $2] : ['&', $_] } + grep { /e/ } + @Testing::EXPORT, @Testing::EXPORT_OK), + 'import by regex'); package Venus; Testing->import('!/e/'); -::ok( (!grep { eval "defined $_" } map { /^\w/ ? "&$_" : $_ } - grep { /e/ } @Testing::EXPORT, @Testing::EXPORT_OK), - 'deny import by regex'); +::ok( (! grep { my ($s, $n) = @$_; eval "\\$s$n == \\${s}Testing::$n" } + map { /^(\W)(\w+)/ ? [$1, $2] : ['&', $_] } + grep { /e/ } + @Testing::EXPORT, @Testing::EXPORT_OK), + 'deny import by regex'); + ::ok( !defined &lifejacket, 'further denial' ); @@ -171,7 +180,7 @@ eval { Yet::More::Testing->require_version(10); 1 }; my $warnings; BEGIN { - $SIG{__WARN__} = sub { $warnings = join '', @_ }; + local $SIG{__WARN__} = sub { $warnings = join '', @_ }; package Testing::Unused::Vars; @ISA = qw(Exporter); @EXPORT = qw(this $TODO that); @@ -206,7 +215,6 @@ package The::Import; use Exporter 'import'; -eval { import() }; ::ok(\&import == \&Exporter::import, "imported the import routine"); @EXPORT = qw( wibble ); @@ -219,3 +227,9 @@ The::Import->import; my $val = eval { wibble() }; ::ok($val eq "wobble", "exported importer worked"); +# Check that Carp recognizes Exporter as internal to Perl +require Carp; +eval { Carp::croak() }; +::ok($Carp::Internal{Exporter}, "Carp recognizes Exporter"); +::ok($Carp::Internal{'Exporter::Heavy'}, "Carp recognizes Exporter::Heavy"); +