diff options
author | Jerry D. Hedden <jdhedden@cpan.org> | 2009-10-27 13:25:51 -0400 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-10-28 22:19:28 +0100 |
commit | 4817af0025b173cce20eae1ea6745f2864162edc (patch) | |
tree | da7a4f6f208c3ec47210bdb6d43a137f17b49dd0 /lib/Exporter.t | |
parent | 46655c69f462f3f5601767d8623cc2b70914d76c (diff) | |
download | perl-4817af0025b173cce20eae1ea6745f2864162edc.tar.gz |
Test exported arrays and hashes without using defined()
Diffstat (limited to 'lib/Exporter.t')
-rw-r--r-- | lib/Exporter.t | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/Exporter.t b/lib/Exporter.t index 20f6ad31f3..0e69cb194d 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' ); |