From: David Golden Date: Tue, 20 Oct 2009 01:42:28 +0000 (-0400) Subject: Revised Module::CoreList::is_deprecated X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dee1c27c65612712346c083a2ec5ea1af81405c;p=p5sagit%2Fp5-mst-13.2.git Revised Module::CoreList::is_deprecated The is_deprecated() function now expects to be called as a function, not a method to be consistent with other Module::CoreList functions. The %deprecated hash now is versioned by Perl version, so tests and is_deprecated are revised accordingly. --- diff --git a/dist/Module-CoreList/lib/Module/CoreList.pm b/dist/Module-CoreList/lib/Module/CoreList.pm index 6ddcbbe..bdfbbe2 100644 --- a/dist/Module-CoreList/lib/Module/CoreList.pm +++ b/dist/Module-CoreList/lib/Module/CoreList.pm @@ -49,6 +49,10 @@ Since 2.11, Module::CoreList::first_release() returns the first release in the order of perl version numbers. If you want to get the earliest perl release instead, use Module::CoreList::first_release_by_date(). +New in 2.22, Module::CoreList::deprecated(MODULE,PERL_VERSION) returns true +if MODULE is marked as deprecated in PERL_VERSION. If PERL_VERSION is +omitted, it defaults to the current version of Perl. + =head1 CAVEATS Module::CoreList currently covers the 5.000, 5.001, 5.002, 5.003_07, 5.004, @@ -139,11 +143,10 @@ sub find_version { } 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 }; + my ($module, $perl_version) = @_; + $perl_version ||= $]; + return unless $module && exists $deprecated{$perl_version}{$module}; + return $deprecated{$perl_version}{$module}; } # When things escaped. @@ -11871,11 +11874,6 @@ 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 $released{'5.000'} = $released{5}; diff --git a/dist/Module-CoreList/t/deprecated.t b/dist/Module-CoreList/t/deprecated.t index 151b6c0..8ee1825 100644 --- a/dist/Module-CoreList/t/deprecated.t +++ b/dist/Module-CoreList/t/deprecated.t @@ -1,8 +1,27 @@ #!perl -w use strict; -use Module::CoreList; -use Test::More tests => 3; +use Test::More tests => 7; -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'); +require_ok('Module::CoreList'); + +ok($Module::CoreList::deprecated{5.011000}, "5.011000 (deprecated list)"); + +ok(!exists $Module::CoreList::deprecated{5.011000}{'File::Spec'}, + "File::Spec not deprecated in 5.011000 (hash)" +); + +ok(! Module::CoreList::is_deprecated('File::Spec'), + "File::Spec not deprecated in 5.011000 (function)" +); + +ok(exists $Module::CoreList::deprecated{5.011000}{'Switch'}, + "Switch deprecated in 5.011000 (hash)" +); + +is(!! Module::CoreList::is_deprecated('Switch'), !! $] >= 5.011, + "Switch deprecated current perl (function)" +); + +ok(! Module::CoreList::is_deprecated('Switch', 5.010000), + "Switch not deprecated in 5.010000 (function w/ perl version)" +);