This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Module::Metadata 1.000026
authorKaren Etheridge <ether@cpan.org>
Sat, 17 Jan 2015 19:31:47 +0000 (11:31 -0800)
committerJames E Keenan <jkeenan@cpan.org>
Sun, 18 Jan 2015 02:58:25 +0000 (21:58 -0500)
cpan/Module-Metadata/lib/Module/Metadata.pm
cpan/Module-Metadata/t/metadata.t

index dddfedb..7ea1210 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
 # vim:ts=8:sw=2:et:sta:sts=2
-package Module::Metadata; # git description: v1.000024-12-g978f25c
+package Module::Metadata; # git description: v1.000025-7-g47ca1b2
 
 # Adapted from Perl-licensed code originally distributed with
 # Module-Build by Ken Williams
@@ -13,7 +13,7 @@ sub __clean_eval { eval $_[0] }
 use strict;
 use warnings;
 
-our $VERSION = '1.000025';
+our $VERSION = '1.000026';
 
 use Carp qw/croak/;
 use File::Spec;
index 3d55111..ca92863 100644 (file)
@@ -237,6 +237,11 @@ our $VERSION     = '1.12.B55J2qn'; our $WTF = $VERSION; $WTF =~ s/^\d+\.\d+\.//;
 package Simple;
 { our $VERSION = '1.12'; }
 ---
+  sub { defined $_[0] and $_[0] =~ /^3\.14159/ } => <<'---', # calculated version - from Acme-Pi-3.14
+package Simple;
+my $version = atan2(1,1) * 4; $Simple::VERSION = "$version";
+1;
+---
 );
 
 # format: expected package name => code snippet
@@ -308,12 +313,12 @@ sub tmpdir {
 }
 
 my $tmp;
-BEGIN { $tmp = tmpdir; diag "using temp dir $tmp"; }
+BEGIN { $tmp = tmpdir; note "using temp dir $tmp"; }
 
 END {
   die "tests failed; leaving temp dir $tmp behind"
     if $ENV{AUTHOR_TESTING} and not Test::Builder->new->is_passing;
-  diag "removing temp dir $tmp";
+  note "removing temp dir $tmp";
   chdir original_cwd;
   File::Path::rmtree($tmp);
 }
@@ -415,14 +420,24 @@ while (++$test_case and my ($expected_version, $code) = splice @modules, 0, 2 )
     # We want to ensure we preserve the original, as long as it's legal, so we
     # explicitly check the stringified form.
     isa_ok($got, 'version') if defined $expected_version;
-    is(
-      (defined $got ? "$got" : $got),
-      $expected_version,
-      "case $test_case: correct module version ("
-        . (defined $expected_version? "'$expected_version'" : 'undef')
-        . ')'
-    )
-    or $errs++;
+
+    if (ref($expected_version) eq 'CODE') {
+      ok(
+        $expected_version->($got),
+        "case $test_case: module version passes match sub"
+      )
+      or $errs++;
+    }
+    else {
+      is(
+        (defined $got ? "$got" : $got),
+        $expected_version,
+        "case $test_case: correct module version ("
+          . (defined $expected_version? "'$expected_version'" : 'undef')
+          . ')'
+      )
+      or $errs++;
+    }
 
     is( $warnings, '', "case $test_case: no warnings from parsing" ) or $errs++;
     diag Dumper({ got => $pm_info->version, module_contents => $code }) if $errs;