diff options
author | Chad Granum <exodist7@gmail.com> | 2016-01-23 18:07:45 -0800 |
---|---|---|
committer | Chad Granum <exodist7@gmail.com> | 2016-01-23 18:07:45 -0800 |
commit | 1bda85db2ae394a511656fb351bae21f44731f2f (patch) | |
tree | 4e3fb93101c6eee084cfebe9b9d0ba99cd4b34bd | |
parent | a84bf807e5b3f70e707c0678e969577ce68b4b7f (diff) |
Fix export_fail args
-rw-r--r-- | lib/Importer.pm | 5 | ||||
-rw-r--r-- | t/export_fail.t | 28 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/Importer.pm b/lib/Importer.pm index 2b5689b..0ac974a 100644 --- a/lib/Importer.pm +++ b/lib/Importer.pm @@ -477,9 +477,10 @@ sub _handle_fail { my $from = $self->from; my $menu = $self->menu($into); - my @fail = grep $menu->{fail}->{$_->[0]}, @$import or return; + # Historically Exporter would strip the '&' off of sub names passed into export_fail. + my @fail = map {my $x = $_->[0]; $x =~ s/^&//; $x} grep $menu->{fail}->{$_->[0]}, @$import or return; - my @real_fail = $from->can('export_fail') ? $from->export_fail(map $_->[0], @fail) : map $_->[0], @fail; + my @real_fail = $from->can('export_fail') ? $from->export_fail(@fail) : @fail; if (@real_fail) { $self->carp(qq["$_" is not implemented by the $from module on this architecture]) diff --git a/t/export_fail.t b/t/export_fail.t new file mode 100644 index 0000000..98383ce --- /dev/null +++ b/t/export_fail.t @@ -0,0 +1,28 @@ +use strict; +use warnings; + +use Test::More; + +my @got; +BEGIN { + $INC{'FAIL.pm'} = 1; + package FAIL; + + our @EXPORT = qw/foo $bar/; + our @EXPORT_FAIL = qw/foo $bar/; + + sub export_fail { + @got = @_; + return(); + } +} + +use Importer FAIL => qw/&foo $bar/; + +is_deeply( + \@got, + [qw/FAIL foo $bar/], + "'&' stripped from sub export" +); + +done_testing; |