whitespace fixes
[p5sagit/Module-Metadata.git] / t / metadata.t
index 286b1ae..c72b306 100644 (file)
@@ -3,7 +3,9 @@
 # vim:ts=8:sw=2:et:sta:sts=2
 
 use strict;
+use warnings;
 use lib 't/lib';
+use Test::More;
 use IO::File;
 use MBTest;
 
@@ -209,6 +211,12 @@ package Simple v1.2.3_4 {
   1;
 }
 ---
+  '0' => <<'---', # set from separately-initialised variable
+package Simple;
+  our $CVSVERSION   = '$Revision: 1.7 $';
+  our ($VERSION)    = ($CVSVERSION =~ /(\d+\.\d+)/);
+}
+---
 );
 my %modules = reverse @modules;
 
@@ -252,7 +260,7 @@ package Simple-Edward;
 );
 my %pkg_names = reverse @pkg_names;
 
-plan tests => 54 + (2 * keys( %modules )) + (2 * keys( %pkg_names ));
+plan tests => 63 + (2 * keys( %modules )) + (2 * keys( %pkg_names ));
 
 require_ok('Module::Metadata');
 
@@ -274,7 +282,7 @@ $dist->chdir_in;
 
 # fail on invalid module name
 my $pm_info = Module::Metadata->new_from_module(
-               'Foo::Bar', inc => [] );
+                'Foo::Bar', inc => [] );
 ok( !defined( $pm_info ), 'fail if can\'t find module by module name' );
 
 
@@ -299,7 +307,7 @@ close($handle);
 
 # construct from module name, using custom include path
 $pm_info = Module::Metadata->new_from_module(
-            $dist->name, inc => [ 'lib', @INC ] );
+             $dist->name, inc => [ 'lib', @INC ] );
 ok( defined( $pm_info ), 'new_from_module() succeeds' );
 
 
@@ -470,7 +478,7 @@ foreach my $script ( @scripts ) {
   $dist->change_file( 'bin/simple.plx', $script );
   $dist->regen;
   $pm_info = Module::Metadata->new_from_file(
-              File::Spec->catfile( 'bin', 'simple.plx' ) );
+               File::Spec->catfile( 'bin', 'simple.plx' ) );
 
   is( $pm_info->version, '0.01', "correct script version ($i of $n)" );
   $i++;
@@ -717,6 +725,9 @@ $VERSION = '0.01';
   is( $pm_info->version, undef, 'version for default package' );
   is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
   is( $pm_info->version('Simple'), undef, 'version for capitalized package' );
+  ok( $pm_info->is_indexable(), 'an indexable package is found' );
+  ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
+  ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
 
   $dist->change_file( 'lib/Simple.pm', <<'---' );
 package simple;
@@ -734,4 +745,20 @@ $VERSION = '0.03';
   is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
   is( $pm_info->version('Simple'), '0.02', 'version for capitalized package' );
   is( $pm_info->version('SiMpLe'), '0.03', 'version for mixed-case package' );
+  ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
+  ok( $pm_info->is_indexable('Simple'), 'the Simple package is indexable' );
+
+  $dist->change_file( 'lib/Simple.pm', <<'---' );
+package ## hide from PAUSE
+   simple;
+$VERSION = '0.01';
+---
+
+  $dist->regen;
+
+  $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
+  is( $pm_info->name, undef, 'no package names found' );
+  ok( !$pm_info->is_indexable('simple'), 'the simple package would not be indexed' );
+  ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
+  ok( !$pm_info->is_indexable(), 'no indexable package is found' );
 }