From: Leon Timmermans Date: Sat, 11 Aug 2012 11:08:17 +0000 (+0300) Subject: Warn if defaults are not in exports X-Git-Tag: v0.001005~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb7b321b00905359efa9aa2f13abf44b01887817;p=p5sagit%2FSub-Exporter-Progressive.git Warn if defaults are not in exports --- diff --git a/Changes b/Changes index 8af0ac1..9f0680e 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ + - Warn if defaults are not in exports + 0.001004 - 2012-08-09 - fix skipping when Sub::Exporter isn't installed diff --git a/lib/Sub/Exporter/Progressive.pm b/lib/Sub/Exporter/Progressive.pm index 5cb4e7d..53fe5a3 100644 --- a/lib/Sub/Exporter/Progressive.pm +++ b/lib/Sub/Exporter/Progressive.pm @@ -11,7 +11,7 @@ sub import { my ($self, @args) = @_; my $inner_target = caller(0); - my ($TOO_COMPLICATED, $export_data) = sub_export_options(@args); + my ($TOO_COMPLICATED, $export_data) = sub_export_options($inner_target, @args); die <<'DEATH' if $TOO_COMPLICATED; You are using Sub::Exporter::Progressive, but the features your program uses from @@ -42,7 +42,7 @@ DEATH } sub sub_export_options { - my ($setup, $options) = @_; + my ($inner_target, $setup, $options) = @_; my $TOO_COMPLICATED = 0; @@ -76,6 +76,8 @@ sub sub_export_options { } } @defaults = @exports if @defaults && $defaults[0] eq '-all'; + my @errors = grep { my $default = $_; !grep { $default eq $_ } @exports } @defaults; + die join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; } return $TOO_COMPLICATED, { diff --git a/t/lib/A/Junk.pm b/t/lib/A/Junk.pm index 3f0d7c8..112344b 100644 --- a/t/lib/A/Junk.pm +++ b/t/lib/A/Junk.pm @@ -1,7 +1,7 @@ package A::Junk; use Sub::Exporter::Progressive -setup => { - exports => [qw(junk1)], + exports => [qw(junk1 junk2)], groups => { default => ['junk2'], },