summaryrefslogtreecommitdiff
path: root/cpan/Module-Metadata/t/metadata.t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/Module-Metadata/t/metadata.t')
-rw-r--r--cpan/Module-Metadata/t/metadata.t81
1 files changed, 80 insertions, 1 deletions
diff --git a/cpan/Module-Metadata/t/metadata.t b/cpan/Module-Metadata/t/metadata.t
index c0e0f12464..b93cefbe78 100644
--- a/cpan/Module-Metadata/t/metadata.t
+++ b/cpan/Module-Metadata/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 => 42 + 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,81 @@ $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;
+
+{
+ my $got_provides = Module::Metadata->provides(dir => 'lib');
+ my $exp_provides = {
+ 'Simple' => {
+ 'file' => 'lib/Simple.pm',
+ 'version' => '0.01'
+ },
+ 'Simple::Ex' => {
+ 'file' => 'lib/Simple.pm',
+ 'version' => '0.02'
+ }
+ };
+
+ is_deeply( $got_provides, $exp_provides, "provides()" )
+ or diag explain $got_provides;
+}
+
+{
+ my $got_provides = Module::Metadata->provides(dir => 'lib', prefix => 'other');
+ my $exp_provides = {
+ 'Simple' => {
+ 'file' => 'other/Simple.pm',
+ 'version' => '0.01'
+ },
+ 'Simple::Ex' => {
+ 'file' => 'other/Simple.pm',
+ 'version' => '0.02'
+ }
+ };
+
+ is_deeply( $got_provides, $exp_provides, "provides()" )
+ or diag explain $got_provides;
+}