Author: kwilliams
Date: Sat Jul 29 19:57:40 2006
New Revision: 6729

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/ModuleInfo.pm
   Module-Build/trunk/t/moduleinfo.t

Log:
Don't look for VERSIONs after __DATA__ or __END__

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Sat Jul 29 19:57:40 2006
@@ -28,6 +28,9 @@
    same as the one initially used to run the Build.PL.  Use with
    caution.
 
+ - Module::Build::ModuleInfo will no longer detect things that look
+   like $VERSION assignments after an __END__ or __DATA__ token.
+
 0.2804  Sun Jul 16 16:41:25 CDT 2006
 
  - Added 'use version;' in Module::Build::Version, because some

Modified: Module-Build/trunk/lib/Module/Build/ModuleInfo.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/ModuleInfo.pm   (original)
+++ Module-Build/trunk/lib/Module/Build/ModuleInfo.pm   Sat Jul 29 19:57:40 2006
@@ -176,6 +176,9 @@
 
     $in_pod = ($line =~ /^=(?!cut)/) ? 1 : ($line =~ /^=cut/) ? 0 : $in_pod;
 
+    # Would be nice if we could also check $in_string or something too
+    last if !$in_pod && $line =~ /^__(?:DATA|END)__$/;
+
     if ( $in_pod || $line =~ /^=cut/ ) {
 
       if ( $line =~ /^=head\d\s+(.+)\s*$/ ) {

Modified: Module-Build/trunk/t/moduleinfo.t
==============================================================================
--- Module-Build/trunk/t/moduleinfo.t   (original)
+++ Module-Build/trunk/t/moduleinfo.t   Sat Jul 29 19:57:40 2006
@@ -2,7 +2,7 @@
 
 use strict;
 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 72;
+use MBTest tests => 75;
 
 use Cwd ();
 my $cwd = Cwd::cwd;
@@ -346,7 +346,6 @@
              $dist->name, inc => [ 'lib', @INC ] );
 
 is( $pm_info->name, 'Simple', 'found default package' );
-
 is( $pm_info->version, '0.01', 'version for default package' );
 
 # got correct version for secondary package
@@ -386,8 +385,28 @@
 is( $name, q|Simple - It's easy.|, 'collected pod section' );
 
 
+{
+  # examine properties of a module: name, pod, etc
+  $dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '0.01';
+__DATA__
+*UNIVERSAL::VERSION = sub {
+  foo();
+};
+---
+  $dist->regen;
+
+  $pm_info = Module::Build::ModuleInfo->new_from_file('lib/Simple.pm');
+  is( $pm_info->name, 'Simple', 'found default package' );
+  is( $pm_info->version, '0.01', 'version for default package' );
+  my @packages = $pm_info->packages_inside;
+  is_deeply([EMAIL PROTECTED], ['Simple']);
+}
+
+
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
 
 use File::Path;

Reply via email to