This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
46655c6
)
Test exported arrays and hashes without using defined()
author
Jerry D. Hedden
<jdhedden@cpan.org>
Tue, 27 Oct 2009 17:25:51 +0000
(13:25 -0400)
committer
Rafael Garcia-Suarez
<rgs@consttype.org>
Wed, 28 Oct 2009 21:19:28 +0000
(22:19 +0100)
lib/Exporter.t
patch
|
blob
|
blame
|
history
diff --git
a/lib/Exporter.t
b/lib/Exporter.t
index
20f6ad3
..
0e69cb1
100644
(file)
--- 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);
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);
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;
package Arrr;
@@
-141,17
+145,22
@@
Testing->import(qw(!lifejacket));
package Mars;
Testing->import('/e/');
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/');
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' );
::ok( !defined &lifejacket, 'further denial' );