From: David Golden Date: Tue, 7 Feb 2012 19:37:52 +0000 (-0500) Subject: test package_versions_from_directory X-Git-Tag: release_1.0.8~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=388bf28253bd1f10013ca7a83820b5a9d8a54598;p=p5sagit%2FModule-Metadata.git test package_versions_from_directory --- diff --git a/t/metadata.t b/t/metadata.t index c0e0f12..ed34351 100644 --- a/t/metadata.t +++ b/t/metadata.t @@ -203,7 +203,7 @@ package Simple v1.2.3_4 { ); my %modules = reverse @modules; -plan tests => 39 + 2 * keys( %modules ); +plan tests => 40 + 2 * keys( %modules ); require_ok('Module::Metadata'); @@ -411,6 +411,7 @@ package Simple; $VERSION = '0.01'; package Simple::Ex; $VERSION = '0.02'; + =head1 NAME Simple - It's easy. @@ -503,3 +504,47 @@ $VERSION = version->new('0.61.' . (qw$Revision: 129 $)[1]); is( $pm_info->version('Simple::Simon'), '0.61.129', 'version for embedded package' ); } +# check that package_versions_from_directory works + +$dist->change_file( 'lib/Simple.pm', <<'---' ); +package Simple; +$VERSION = '0.01'; +package Simple::Ex; +$VERSION = '0.02'; +{ + package main; # should ignore this +} +{ + package DB; # should ignore this +} +{ + package Simple::_private; # should ignore this +} + +=head1 NAME + +Simple - It's easy. + +=head1 AUTHOR + +Simple Simon + +=cut +--- +$dist->regen; + +my $exp_pvfd = { + 'Simple' => { + 'file' => 'Simple.pm', + 'version' => '0.01' + }, + 'Simple::Ex' => { + 'file' => 'Simple.pm', + 'version' => '0.02' + } +}; + +my $got_pvfd = Module::Metadata->package_versions_from_directory('lib'); + +is_deeply( $got_pvfd, $exp_pvfd, "package_version_from_directory" ) + or diag explain $got_pvfd;