From: Chris Williams Date: Tue, 20 Oct 2009 23:01:18 +0000 (+0100) Subject: Module::CoreList, implemented is_deprecated() and added tests for it. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c77945c3ac1accefe435a4ba5074a4f9257b4bf9;p=p5sagit%2Fp5-mst-13.2.git Module::CoreList, implemented is_deprecated() and added tests for it. Module::CoreList->is_deprecated( 'Switch' ); # assumes $] Module::CoreList->is_deprecated( 'Switch', 5.01000 ); --- diff --git a/MANIFEST b/MANIFEST index 7d247df..3aad396 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2687,6 +2687,7 @@ dist/Module-CoreList/MANIFEST Module::CoreList dist/Module-CoreList/META.yml Module::CoreList dist/Module-CoreList/README Module::CoreList dist/Module-CoreList/t/corelist.t Module::CoreList tests +dist/Module-CoreList/t/deprecated.t Module::CoreList tests dist/Module-CoreList/t/find_modules.t Module::CoreList tests dist/Module-CoreList/t/pod.t Module::CoreList tests dist/Net-Ping/Changes Net::Ping diff --git a/dist/Module-CoreList/MANIFEST b/dist/Module-CoreList/MANIFEST index 0afea85..bbf88df 100644 --- a/dist/Module-CoreList/MANIFEST +++ b/dist/Module-CoreList/MANIFEST @@ -7,5 +7,6 @@ MANIFEST Makefile.PL META.yml t/corelist.t +t/deprecated.t t/find_modules.t t/pod.t diff --git a/dist/Module-CoreList/lib/Module/CoreList.pm b/dist/Module-CoreList/lib/Module/CoreList.pm index 029ee3d..f5ccf0e 100644 --- a/dist/Module-CoreList/lib/Module/CoreList.pm +++ b/dist/Module-CoreList/lib/Module/CoreList.pm @@ -1,8 +1,8 @@ package Module::CoreList; use strict; use vars qw/$VERSION %released %version %families %upstream - %bug_tracker/; -$VERSION = '2.21'; + %bug_tracker %deprecated/; +$VERSION = '2.22'; =head1 NAME @@ -138,6 +138,14 @@ sub find_version { return undef; } +sub is_deprecated { + my ($discard, $module, $perl) = @_; + return unless $module and exists $deprecated{ $module }; + $perl = $] unless $perl and exists $version{ $perl }; + return $deprecated{ $module } if + $perl >= $deprecated{ $module }; +} + # When things escaped. # NB. If you put version numbers with trailing zeroes here, you # should also add an alias for the numerical ($]) version; see @@ -11848,6 +11856,10 @@ for my $version ( sort { $a <=> $b } keys %released ) { 'version' => undef, ); +# Deprecated modules and the version they were deprecated +%deprecated = ( + 'Switch' => '5.011', +); # Create aliases with trailing zeros for $] use diff --git a/dist/Module-CoreList/t/deprecated.t b/dist/Module-CoreList/t/deprecated.t new file mode 100644 index 0000000..151b6c0 --- /dev/null +++ b/dist/Module-CoreList/t/deprecated.t @@ -0,0 +1,8 @@ +#!perl -w +use strict; +use Module::CoreList; +use Test::More tests => 3; + +is(Module::CoreList->is_deprecated('Switch',5.011),'5.011','Switch is deprecated'); +is(Module::CoreList->is_deprecated('Switch',5.011000),'5.011','Switch is deprecated using $]'); +is(Module::CoreList->is_deprecated('Switch',5.010),'','Switch is not deprecated');