return 0 if defined($final_release) && $perl_version > $final_release;
# If a minimum version of the module was specified:
- # Step through all perl release numbers ($prn)
- # in order, so we can find what version of the module
+ # Step through all perl releases ($prn)
+ # so we can find what version of the module
# was included in the specified version of perl.
# On the way if we pass the required module version, we can
# short-circuit and return true
if (defined($module_version)) {
+ # The Perl releases aren't a linear sequence, but a tree. We need to build the path
+ # of releases from 5 to the specified release, and follow the module's version(s)
+ # along that path.
+ my @releases = ($perl_version);
+ my $rel = $perl_version;
+ while (defined($rel)) {
+ $rel = $delta{$rel}->{delta_from};
+ unshift(@releases, $rel) if defined($rel);
+ }
RELEASE:
- foreach my $prn (sort keys %delta) {
+ foreach my $prn (@releases) {
next RELEASE if $prn <= $first_release;
last RELEASE if $prn > $perl_version;
next unless defined(my $next_module_version
#!perl -w
use strict;
use Module::CoreList;
-use Test::More tests => 23;
+use Test::More tests => 33;
BEGIN { require_ok('Module::CoreList'); }
ok(!Module::CoreList::is_core('Module::CoreList', undef, '5.007003'), "Module::CoreList wasn't core in perl 5.7.3");
ok(!Module::CoreList->is_core('Module::CoreList', undef, '5.007003'), "Module::CoreList wasn't core in perl 5.7.3 (class method)");
+# Test for situations where different branches on the perl
+# release tree had different versions of a module, and a naive
+# checking of perl release number will trip you up
+ok(Module::CoreList->is_core('Text::Soundex', '1.01', '5.008007'), "Text::Soundex 1.01 was first included in 5.007003");
+ok(Module::CoreList->is_core('Text::Soundex', '3.03', '5.008009'), "Text::Soundex 3.03 was included in 5.008009");
+ok(!Module::CoreList->is_core('Text::Soundex', '3.03', '5.009003'), "5.009003 still had Text::Soundex 1.01");
+ok(Module::CoreList->is_core('Text::Soundex', '1.01', '5.009003'), "5.009003 still had Text::Soundex 1.01");
+ok(!Module::CoreList->is_core('Text::Soundex', '3.03', '5.009005'), "5.009005 still had Text::Soundex 3.02");
+ok(Module::CoreList->is_core('Text::Soundex', '3.02', '5.009005'), "5.009005 had Text::Soundex 3.02");
+ok(Module::CoreList->is_core('Text::Soundex', '3.03', '5.01'), "5.01 had Text::Soundex 3.03");
+
+# 5.002 was the first perl release where core modules had a version number
+ok(Module::CoreList->is_core('DB_File', '1.01', '5.002'), "DB_File 1.01 was included in 5.002");
+ok(!Module::CoreList->is_core('DB_File', '1.03', '5.002'), "DB_File 1.03 wasn't included in 5.002");
+ok(Module::CoreList->is_core('DB_File', '1.03', '5.00307'), "DB_File 1.03 was included in 5.00307");