From: Vincent Pit Date: Mon, 29 Aug 2011 18:05:19 +0000 (+0200) Subject: Test undefined $VERSION X-Git-Tag: release_1.0.6~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FModule-Metadata.git;a=commitdiff_plain;h=975132cb5959d78e63523a3c9f1b9d75631e0ea3 Test undefined $VERSION --- diff --git a/t/metadata.t b/t/metadata.t index 60cb316..b5eda17 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'; @@ -242,11 +251,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; } }