From: Jerry D. Hedden Date: Tue, 27 Oct 2009 17:25:51 +0000 (-0400) Subject: Test exported arrays and hashes without using defined() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4817af0025b173cce20eae1ea6745f2864162edc;p=p5sagit%2Fp5-mst-13.2.git Test exported arrays and hashes without using defined() --- diff --git a/lib/Exporter.t b/lib/Exporter.t index 20f6ad3..0e69cb1 100644 --- a/lib/Exporter.t +++ b/lib/Exporter.t @@ -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' );