In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/ba4fc2b447d5c04e1ada54027c446d03452dcb25?hp=913cec4246caa89e35bb997c168e7ea2dfcadc4f>
- Log ----------------------------------------------------------------- commit ba4fc2b447d5c04e1ada54027c446d03452dcb25 Author: James E Keenan <[email protected]> Date: Tue Jul 7 20:14:58 2015 -0400 Module::CoreList->find_version(): refactor for testability. In order to address weaknesses in the documentation of find_version() in CoreList.pod, we first had to address its lack of unit tests. It was previously only exercised inside the 'corelist' utility. Refactored function a bit to expose all its branches for testing. Then added tests for the function with and without arguments. Corrected documentation for find_version() in CoreList.pod. Documentation subsequently clarified per feedback from Steve Parker. For: RT # 125563 (1st of 2 problems cited in that ticket). M dist/Module-CoreList/lib/Module/CoreList.pm M dist/Module-CoreList/lib/Module/CoreList.pod M dist/Module-CoreList/t/corelist.t commit 7f279091ed7e7241570d4e4abce94248caeb8869 Author: James E Keenan <[email protected]> Date: Tue Jul 7 18:59:40 2015 -0400 Clarify that deprecated_in() returns a perl version. I.e., a string like 5.010001. This makes documentation of deprecated_in() consistent with that of other Module::CoreList functions. For: RT # 125563 (2nd of two problems raised) M dist/Module-CoreList/lib/Module/CoreList.pod ----------------------------------------------------------------------- Summary of changes: dist/Module-CoreList/lib/Module/CoreList.pm | 7 +++++-- dist/Module-CoreList/lib/Module/CoreList.pod | 9 ++++++--- dist/Module-CoreList/t/corelist.t | 11 ++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dist/Module-CoreList/lib/Module/CoreList.pm b/dist/Module-CoreList/lib/Module/CoreList.pm index 49b3763..59316ed 100644 --- a/dist/Module-CoreList/lib/Module/CoreList.pm +++ b/dist/Module-CoreList/lib/Module/CoreList.pm @@ -74,9 +74,12 @@ sub find_modules { sub find_version { my $v = shift; - $v = shift if eval { $v->isa(__PACKAGE__) }; + if ($v->isa(__PACKAGE__)) { + $v = shift; + return if not defined $v; + } return $version{$v} if defined $version{$v}; - return undef; + return; } sub is_deprecated { diff --git a/dist/Module-CoreList/lib/Module/CoreList.pod b/dist/Module-CoreList/lib/Module/CoreList.pod index edc00ec..d8807bf 100644 --- a/dist/Module-CoreList/lib/Module/CoreList.pod +++ b/dist/Module-CoreList/lib/Module/CoreList.pod @@ -73,8 +73,11 @@ you may provide a list of perl versions to limit the regex search. =item C<find_version( PERL_VERSION )> -Takes a perl version as an argument. Returns that perl version if it exists or C<undef> -otherwise. +Takes a perl version as an argument. Upon successful completion, returns a +reference to a hash. Each element of that hash has a key which is the name of +a module (I<e.g.,> 'File::Path') shipped with that version of perl and a value +which is the version number (I<e.g.,> '2.09') of that module which shipped +with that version of perl . Returns C<undef> otherwise. =item C<is_core( MODULE, [ MODULE_VERSION, [ PERL_VERSION ] ] )> @@ -100,7 +103,7 @@ omitted, it defaults to the current version of Perl. Available in version 2.77 and above. -Returns the first PERL_VERSION where the MODULE was marked as deprecated. Returns C<undef> +Returns the first perl version where the MODULE was marked as deprecated. Returns C<undef> if the MODULE has not been marked as deprecated. =item C<removed_from( MODULE )> diff --git a/dist/Module-CoreList/t/corelist.t b/dist/Module-CoreList/t/corelist.t index c129584..db09f48 100644 --- a/dist/Module-CoreList/t/corelist.t +++ b/dist/Module-CoreList/t/corelist.t @@ -1,7 +1,7 @@ #!perl -w use strict; use Module::CoreList; -use Test::More tests => 29; +use Test::More tests => 32; BEGIN { require_ok('Module::CoreList'); } @@ -106,3 +106,12 @@ is(Module::CoreList::removed_from('CPANPLUS::inc'), 5.010001, cmp_ok($warnings_count, '==', 0, "an undefined version does not produce warnings rt#123556"); } + +ok(! defined(Module::CoreList->find_version()), + "Lacking an argument, Module::CoreList->find_version() returns undef"); +my $v = 5.022; +is(ref(Module::CoreList->find_version($v)), 'HASH', + "With argument, Module::CoreList->find_version() returns hashref"); +$v = 5.022000; +is(ref(Module::CoreList->find_version($v)), 'HASH', + "With argument, Module::CoreList->find_version() returns hashref"); -- Perl5 Master Repository
