is_core.t revision 1.2
1#!perl -w 2use strict; 3use Module::CoreList; 4use Test::More tests => 38; 5 6BEGIN { require_ok('Module::CoreList'); } 7 8# Check default perl 9 10ok(Module::CoreList::is_core('IO::File', $Module::CoreList::version{$]}{'IO::File'}), "is_core is self-consistent"); 11 12ok(!Module::CoreList::is_core('Module::Path'), 'Module::Path has never been in core'); 13ok(!Module::CoreList::is_core('Module::Path', undef, '5.016003'), 'Module::Path has never been in core'); 14ok(!Module::CoreList::is_core('Module::Path', undef), 'Module::Path has never been in core'); 15 16# List::Util::PP was added in 5.010001 and removed in 5.017001 17ok(!Module::CoreList::is_core('List::Util::PP', undef, '5.002'), 'List::Util::PP was added in 5.10.1 so not in core in 5.002'); 18ok(Module::CoreList::is_core('List::Util::PP', undef, '5.016003'), 'List::Util::PP was in core in 5.16.3'); 19ok(!Module::CoreList::is_core('List::Util::PP', undef, '5.018001'), 'List::Util::PP was removed in 5.17.1 so not in core in 5.18.1'); 20 21# Carp has always been a core module 22ok(Module::CoreList::is_core('Carp', undef, '5'), 'Carp was a core module in first release of perl 5'); 23ok(Module::CoreList::is_core('Carp', undef, '5.019004'), 'Carp was still a core module in 5.19.4'); 24ok(Module::CoreList::is_core('Carp'), "Carp should be a core module whatever version of perl you're running"); 25 26ok(Module::CoreList::is_core('attributes', undef, '5.00503') == 0, "attributes weren't in 5.00503"); 27ok(Module::CoreList::is_core('attributes', undef, '5.006001') == 1, "attributes were in 5.6.1"); 28ok(Module::CoreList::is_core('Pod::Plainer', undef, '5.012001') == 1, "Pod::Plainer was core in 5.12.1"); 29ok(Module::CoreList::is_core('Pod::Plainer', undef, '5.016003') == 0, "Pod::Plainer was removed in 5.13.1"); 30 31# history of module 'encoding' in core 32# version 1.00 included in 5.007003 33# version 1.35 included in 5.008 34# version 1.47 included in 5.008001 35# version 1.48 included in 5.008003 36# version 2.00 included in 5.008005 37# version 2.01 included in 5.008006 38# version 2.02 included in 5.008008 39# version 2.6_01 included in 5.008009 40# version 2.04 included in 5.009004 41# version 2.06 included in 5.009005 42# version 2.6_01 included in 5.010001 43# version 2.12 included in 5.019001 44 45ok(!Module::CoreList::is_core('encoding', undef, '5'), "encoding wasn't in core in first release of perl 5"); 46ok(!Module::CoreList::is_core('encoding', '1.00', '5'), "encoding 1.00 wasn't in core in first release of perl 5"); 47ok(!Module::CoreList::is_core('encoding', '1.35', '5.007003'), "encoding 1.35 wasn't yet in core in perl 5.007003"); 48ok(Module::CoreList::is_core('encoding', '1.35', '5.008'), "encoding 1.35 was first included in perl 5.008"); 49ok(Module::CoreList::is_core('encoding', '1.35', '5.009004'), "encoding 2.04 (>1.35) was included in 5.009004"); 50ok(Module::CoreList::is_core('encoding', '2.01', '5.008007'), "encoding 2.01 was first in core in perl 5.008006, so was core in 5.8.7"); 51ok(Module::CoreList->is_core('encoding', '2.01', '5.008007'), "encoding 2.01 was first in core in perl 5.008006, so was core in 5.8.7"); 52 53# Module::CoreList (2.17) was first included in 5.008009 54ok(!Module::CoreList::is_core('Module::CoreList', undef, '5.007003'), "Module::CoreList wasn't core in perl 5.7.3"); 55ok(!Module::CoreList->is_core('Module::CoreList', undef, '5.007003'), "Module::CoreList wasn't core in perl 5.7.3 (class method)"); 56 57# Test for situations where different branches on the perl 58# release tree had different versions of a module, and a naive 59# checking of perl release number will trip you up 60ok(Module::CoreList->is_core('Text::Soundex', '1.01', '5.008007'), "Text::Soundex 1.01 was first included in 5.007003"); 61ok(Module::CoreList->is_core('Text::Soundex', '3.03', '5.008009'), "Text::Soundex 3.03 was included in 5.008009"); 62ok(!Module::CoreList->is_core('Text::Soundex', '3.03', '5.009003'), "5.009003 still had Text::Soundex 1.01"); 63ok(Module::CoreList->is_core('Text::Soundex', '1.01', '5.009003'), "5.009003 still had Text::Soundex 1.01"); 64ok(!Module::CoreList->is_core('Text::Soundex', '3.03', '5.009005'), "5.009005 still had Text::Soundex 3.02"); 65ok(Module::CoreList->is_core('Text::Soundex', '3.02', '5.009005'), "5.009005 had Text::Soundex 3.02"); 66ok(Module::CoreList->is_core('Text::Soundex', '3.03', '5.01'), "5.01 had Text::Soundex 3.03"); 67 68# 5.002 was the first perl release where core modules had a version number 69ok(Module::CoreList->is_core('DB_File', '1.01', '5.002'), "DB_File 1.01 was included in 5.002"); 70ok(!Module::CoreList->is_core('DB_File', '1.03', '5.002'), "DB_File 1.03 wasn't included in 5.002"); 71ok(Module::CoreList->is_core('DB_File', '1.03', '5.00307'), "DB_File 1.03 was included in 5.00307"); 72 73ok(! Module::CoreList->is_core("CGI", undef, 5.021), "CGI not in 5.021"); 74ok(! Module::CoreList->is_core("CGI", undef, 5.021001), "CGI not in 5.021001"); 75 76ok( Module::CoreList::is_core("Config", 0, "5.020"), "Config v0+ is in core in 5.020"); 77ok( Module::CoreList::is_core("Config", undef, "5.020"), "Config v(undef) is in core in 7.020"); 78