| 1 |
#!perl -w |
| 2 |
use strict; |
| 3 |
use Module::CoreList; |
| 4 |
use Test::More tests => 34; |
| 5 |
|
| 6 |
BEGIN { require_ok('Module::CoreList'); } |
| 7 |
|
| 8 |
ok($Module::CoreList::version{5.00503}, "5.00503"); |
| 9 |
|
| 10 |
ok(!exists $Module::CoreList::version{5.00503}{attributes}, |
| 11 |
"attributes weren't in 5.00503"); |
| 12 |
|
| 13 |
ok($Module::CoreList::version{5.006001}, "5.006001"); |
| 14 |
|
| 15 |
ok(exists $Module::CoreList::version{'5.006001'}{attributes}, |
| 16 |
"attributes were in 5.6.1"); |
| 17 |
|
| 18 |
ok($Module::CoreList::version{5.007003}, "5.007003"); |
| 19 |
|
| 20 |
ok(exists $Module::CoreList::version{5.007003}{'Attribute::Handlers'}, |
| 21 |
"Attribute::Handlers were bundled with 5.7.3"); |
| 22 |
|
| 23 |
is(Module::CoreList->first_release_by_date('File::Spec'), 5.005, |
| 24 |
"File::Spec was first bundled in 5.005"); |
| 25 |
|
| 26 |
is(Module::CoreList->first_release('File::Spec'), 5.00405, |
| 27 |
"File::Spec was released in perl with lowest version number 5.00405"); |
| 28 |
|
| 29 |
is(Module::CoreList->first_release('File::Spec', 0.82), 5.006_001, |
| 30 |
"File::Spec reached 0.82 with 5.006_001"); |
| 31 |
|
| 32 |
is(Module::CoreList::first_release_by_date('File::Spec'), 5.005, |
| 33 |
"File::Spec was first bundled in 5.005"); |
| 34 |
|
| 35 |
is(Module::CoreList::first_release('File::Spec'), 5.00405, |
| 36 |
"File::Spec was released in perl with lowest version number 5.00405"); |
| 37 |
|
| 38 |
is(Module::CoreList::first_release('File::Spec', 0.82), 5.006_001, |
| 39 |
"File::Spec reached 0.82 with 5.006_001"); |
| 40 |
|
| 41 |
ok(!Module::CoreList::first_release('Filespec'), |
| 42 |
"Filespec was never a core module. It's called VMS::Filespec"); |
| 43 |
|
| 44 |
is_deeply([ sort keys %Module::CoreList::released ], |
| 45 |
[ sort keys %Module::CoreList::version ], |
| 46 |
"have a note of everythings release"); |
| 47 |
|
| 48 |
is_deeply( [ map { |
| 49 |
exists $Module::CoreList::version{ $_ }{FindExt} ? $_ : () |
| 50 |
} keys %Module::CoreList::version ], |
| 51 |
[], "FindExt shouldn't get included rt#6922" ); |
| 52 |
|
| 53 |
|
| 54 |
my $consistent = 1; |
| 55 |
for my $family (values %Module::CoreList::families) { |
| 56 |
my $first = shift @$family; |
| 57 |
my $has = join " ", sort keys %{ $Module::CoreList::versions{ $first } }; |
| 58 |
for my $member (@$family) { |
| 59 |
$has eq join " ", sort keys %{ $Module::CoreList::versions{ $member } } |
| 60 |
or do { diag "$first -> $member family"; $consistent = 0 }; |
| 61 |
} |
| 62 |
} |
| 63 |
is( $consistent, 1, |
| 64 |
"families seem consistent (descendants have same modules as ancestors)" ); |
| 65 |
|
| 66 |
# Check the function API for consistency |
| 67 |
|
| 68 |
is(Module::CoreList->first_release_by_date('Module::CoreList'), 5.009002, |
| 69 |
"Module::CoreList was first bundled in 5.009002"); |
| 70 |
|
| 71 |
is(Module::CoreList->first_release('Module::CoreList'), 5.008009, |
| 72 |
"Module::CoreList was released in perl with lowest version number 5.008009"); |
| 73 |
|
| 74 |
is(Module::CoreList->first_release('Module::CoreList', 2.18), 5.010001, |
| 75 |
"Module::CoreList reached 2.18 with 5.010001"); |
| 76 |
|
| 77 |
is(Module::CoreList::first_release_by_date('Module::CoreList'), 5.009002, |
| 78 |
"Module::CoreList was first bundled in 5.009002"); |
| 79 |
|
| 80 |
is(Module::CoreList::first_release('Module::CoreList'), 5.008009, |
| 81 |
"Module::CoreList was released in perl with lowest version number 5.008009"); |
| 82 |
|
| 83 |
is(Module::CoreList::first_release('Module::CoreList', 2.18), 5.010001, |
| 84 |
"Module::CoreList reached 2.18 with 5.010001"); |
| 85 |
|
| 86 |
is(Module::CoreList->removed_from('CPANPLUS::inc'), 5.010001, |
| 87 |
"CPANPLUS::inc was removed from 5.010001"); |
| 88 |
|
| 89 |
is(Module::CoreList::removed_from('CPANPLUS::inc'), 5.010001, |
| 90 |
"CPANPLUS::inc was removed from 5.010001"); |
| 91 |
|
| 92 |
{ |
| 93 |
my $warnings_count = 0; |
| 94 |
local $SIG{__WARN__} = sub { $warnings_count++ }; |
| 95 |
local $^W = 1; |
| 96 |
|
| 97 |
ok(exists $Module::CoreList::version{5}{strict}, |
| 98 |
"strict was in 5"); |
| 99 |
|
| 100 |
ok(!defined $Module::CoreList::version{5}{strict}, |
| 101 |
"strict had no version in 5"); |
| 102 |
|
| 103 |
is(Module::CoreList::first_release('strict', 1.01), 5.00405, |
| 104 |
"strict reached 1.01 with 5.00405"); |
| 105 |
|
| 106 |
cmp_ok($warnings_count, '==', 0, |
| 107 |
"an undefined version does not produce warnings rt#123556"); |
| 108 |
|
| 109 |
ok(keys %{$Module::CoreList::version{5.023002}} > 0, |
| 110 |
"have recent enough data to test for deep recursion warnings"); |
| 111 |
|
| 112 |
cmp_ok($warnings_count, '==', 0, |
| 113 |
"no deep recursion warnings for newer perl versions"); |
| 114 |
} |
| 115 |
|
| 116 |
ok(! defined(Module::CoreList->find_version()), |
| 117 |
"Lacking an argument, Module::CoreList->find_version() returns undef"); |
| 118 |
my $v = 5.022; |
| 119 |
is(ref(Module::CoreList->find_version($v)), 'HASH', |
| 120 |
"With argument, Module::CoreList->find_version() returns hashref"); |
| 121 |
$v = 5.022000; |
| 122 |
is(ref(Module::CoreList->find_version($v)), 'HASH', |
| 123 |
"With argument, Module::CoreList->find_version() returns hashref"); |