From: Vincent Pit Date: Wed, 15 Dec 2010 23:16:27 +0000 (+0100) Subject: Handle undefined licenses gracefully X-Git-Tag: v0.11~9 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=71afb2b14bce73a68a56efd6c47af106c996232d;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git Handle undefined licenses gracefully --- diff --git a/lib/CPANPLUS/Dist/Gentoo/Maps.pm b/lib/CPANPLUS/Dist/Gentoo/Maps.pm index b9b9611..9c91f85 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Maps.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Maps.pm @@ -67,7 +67,11 @@ my %licenses = ( sub license_c2g { my %seen; - grep !$seen{$_}++, map @{$licenses{+lc} || []}, @_; + + grep !$seen{$_}++, + map @{$licenses{+lc} || []}, + grep defined, + @_; } =head2 C diff --git a/t/13-maps-license.t b/t/13-maps-license.t index 0a19d00..e3119dc 100644 --- a/t/13-maps-license.t +++ b/t/13-maps-license.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 6; use CPANPLUS::Dist::Gentoo::Maps; @@ -12,6 +12,8 @@ sub check_licenses { is_deeply \@licenses, $_[1], $_[2]; } +check_licenses [ ], [ ], 'empty'; +check_licenses [ undef ], [ ], 'undef'; check_licenses [ 'woo' ], [ ], 'nonexistent'; check_licenses [ 'perl' ], [ qw/Artistic GPL-2/ ], 'perl'; check_licenses [ qw/perl gpl2/ ], [ qw/Artistic GPL-2/ ], 'perl + gpl2';