X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fmetadata.t;h=c0e0f124643568ed3567582f295f9b732144f1cc;hb=710f253fd2a61c4545f1edf7811bc102d70d8caa;hp=60cb31651d46026a2fac10f692cc7181c1712032;hpb=f33c0a6c2cb3a0cd474d9368d7cbec39e9fd04fe;p=p5sagit%2FModule-Metadata.git diff --git a/t/metadata.t b/t/metadata.t index 60cb316..c0e0f12 100644 --- a/t/metadata.t +++ b/t/metadata.t @@ -7,9 +7,18 @@ use lib 't/lib'; use IO::File; use MBTest; +my $undef; + # parse various module $VERSION lines # these will be reversed later to create %modules my @modules = ( + $undef => <<'---', # no $VERSION line +package Simple; +--- + $undef => <<'---', # undefined $VERSION +package Simple; +our $VERSION; +--- '1.23' => <<'---', # declared & defined on same line with 'our' package Simple; our $VERSION = '1.23'; @@ -171,6 +180,26 @@ our $VERSION = '1.23_00_00'; our $VERSION; $VERSION = 'onetwothree'; --- + $undef => <<'---', # package NAME BLOCK, undef $VERSION +package Simple { + our $VERSION; +} +--- + '1.23' => <<'---', # package NAME BLOCK, with $VERSION +package Simple { + our $VERSION = '1.23'; +} +--- + '1.23' => <<'---', # package NAME VERSION BLOCK +package Simple 1.23 { + 1; +} +--- + 'v1.2.3_4' => <<'---', # package NAME VERSION BLOCK +package Simple v1.2.3_4 { + 1; +} +--- ); my %modules = reverse @modules; @@ -242,11 +271,18 @@ foreach my $module ( sort keys %modules ) { # Test::Builder will prematurely numify objects, so use this form my $errs; - ok( $pm_info->version eq $expected, - "correct module version (expected '$expected')" ) - or $errs++; + my $got = $pm_info->version; + if ( defined $expected ) { + ok( $got eq $expected, + "correct module version (expected '$expected')" ) + or $errs++; + } else { + ok( !defined($got), + "correct module version (expected undef)" ) + or $errs++; + } is( $warnings, '', 'no warnings from parsing' ) or $errs++; - diag "Got: '@{[$pm_info->version]}'\nModule contents:\n$module" if $errs; + diag "Got: '$got'\nModule contents:\n$module" if $errs; } }