remove more unused MB cruft
[p5sagit/Module-Metadata.git] / t / metadata.t
CommitLineData
7a4e305a 1#!/usr/bin/perl -w
2# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
3# vim:ts=8:sw=2:et:sta:sts=2
4
5use strict;
eed8b6fa 6use warnings;
7a4e305a 7use lib 't/lib';
c8b69ebe 8use Test::More;
f33c0a6c 9use IO::File;
7a4e305a 10use MBTest;
11
975132cb 12my $undef;
13
7a4e305a 14# parse various module $VERSION lines
15# these will be reversed later to create %modules
16my @modules = (
975132cb 17 $undef => <<'---', # no $VERSION line
18package Simple;
19---
20 $undef => <<'---', # undefined $VERSION
21package Simple;
22our $VERSION;
23---
7a4e305a 24 '1.23' => <<'---', # declared & defined on same line with 'our'
25package Simple;
26our $VERSION = '1.23';
27---
28 '1.23' => <<'---', # declared & defined on separate lines with 'our'
29package Simple;
30our $VERSION;
31$VERSION = '1.23';
32---
ad924b83 33 '1.23' => <<'---', # commented & defined on same line
34package Simple;
35our $VERSION = '1.23'; # our $VERSION = '4.56';
36---
37 '1.23' => <<'---', # commented & defined on separate lines
38package Simple;
39# our $VERSION = '4.56';
40our $VERSION = '1.23';
41---
7a4e305a 42 '1.23' => <<'---', # use vars
43package Simple;
44use vars qw( $VERSION );
45$VERSION = '1.23';
46---
47 '1.23' => <<'---', # choose the right default package based on package/file name
48package Simple::_private;
49$VERSION = '0';
50package Simple;
51$VERSION = '1.23'; # this should be chosen for version
52---
53 '1.23' => <<'---', # just read the first $VERSION line
54package Simple;
55$VERSION = '1.23'; # we should see this line
56$VERSION = eval $VERSION; # and ignore this one
57---
58 '1.23' => <<'---', # just read the first $VERSION line in reopened package (1)
59package Simple;
60$VERSION = '1.23';
61package Error::Simple;
62$VERSION = '2.34';
63package Simple;
64---
65 '1.23' => <<'---', # just read the first $VERSION line in reopened package (2)
66package Simple;
67package Error::Simple;
68$VERSION = '2.34';
69package Simple;
70$VERSION = '1.23';
71---
72 '1.23' => <<'---', # mentions another module's $VERSION
73package Simple;
74$VERSION = '1.23';
75if ( $Other::VERSION ) {
76 # whatever
77}
78---
79 '1.23' => <<'---', # mentions another module's $VERSION in a different package
80package Simple;
81$VERSION = '1.23';
82package Simple2;
83if ( $Simple::VERSION ) {
84 # whatever
85}
86---
87 '1.23' => <<'---', # $VERSION checked only in assignments, not regexp ops
88package Simple;
89$VERSION = '1.23';
90if ( $VERSION =~ /1\.23/ ) {
91 # whatever
92}
93---
94 '1.23' => <<'---', # $VERSION checked only in assignments, not relational ops
95package Simple;
96$VERSION = '1.23';
97if ( $VERSION == 3.45 ) {
98 # whatever
99}
100---
101 '1.23' => <<'---', # $VERSION checked only in assignments, not relational ops
102package Simple;
103$VERSION = '1.23';
104package Simple2;
105if ( $Simple::VERSION == 3.45 ) {
106 # whatever
107}
108---
109 '1.23' => <<'---', # Fully qualified $VERSION declared in package
110package Simple;
111$Simple::VERSION = 1.23;
112---
113 '1.23' => <<'---', # Differentiate fully qualified $VERSION in a package
114package Simple;
115$Simple2::VERSION = '999';
116$Simple::VERSION = 1.23;
117---
118 '1.23' => <<'---', # Differentiate fully qualified $VERSION and unqualified
119package Simple;
120$Simple2::VERSION = '999';
121$VERSION = 1.23;
122---
123 '1.23' => <<'---', # $VERSION declared as package variable from within 'main' package
124$Simple::VERSION = '1.23';
125{
126 package Simple;
127 $x = $y, $cats = $dogs;
128}
129---
130 '1.23' => <<'---', # $VERSION wrapped in parens - space inside
131package Simple;
132( $VERSION ) = '1.23';
133---
134 '1.23' => <<'---', # $VERSION wrapped in parens - no space inside
135package Simple;
136($VERSION) = '1.23';
137---
138 '1.23' => <<'---', # $VERSION follows a spurious 'package' in a quoted construct
139package Simple;
140__PACKAGE__->mk_accessors(qw(
141 program socket proc
142 package filename line codeline subroutine finished));
143
144our $VERSION = "1.23";
145---
146 '1.23' => <<'---', # $VERSION using version.pm
147 package Simple;
148 use version; our $VERSION = version->new('1.23');
149---
150 '1.23' => <<'---', # $VERSION using version.pm and qv()
151 package Simple;
152 use version; our $VERSION = qv('1.230');
153---
154 '1.23' => <<'---', # Two version assignments, should ignore second one
155 $Simple::VERSION = '1.230';
156 $Simple::VERSION = eval $Simple::VERSION;
157---
158 '1.23' => <<'---', # declared & defined on same line with 'our'
159package Simple;
160our $VERSION = '1.23_00_00';
161---
162 '1.23' => <<'---', # package NAME VERSION
163 package Simple 1.23;
164---
165 '1.23_01' => <<'---', # package NAME VERSION
166 package Simple 1.23_01;
167---
168 'v1.2.3' => <<'---', # package NAME VERSION
169 package Simple v1.2.3;
170---
171 'v1.2_3' => <<'---', # package NAME VERSION
172 package Simple v1.2_3;
173---
92ad06ed 174 '1.23' => <<'---', # trailing crud
175 package Simple;
176 our $VERSION;
177 $VERSION = '1.23-alpha';
178---
179 '1.23' => <<'---', # trailing crud
180 package Simple;
181 our $VERSION;
182 $VERSION = '1.23b';
183---
184 '1.234' => <<'---', # multi_underscore
185 package Simple;
186 our $VERSION;
187 $VERSION = '1.2_3_4';
188---
189 '0' => <<'---', # non-numeric
190 package Simple;
191 our $VERSION;
192 $VERSION = 'onetwothree';
193---
710f253f 194 $undef => <<'---', # package NAME BLOCK, undef $VERSION
195package Simple {
196 our $VERSION;
197}
198---
199 '1.23' => <<'---', # package NAME BLOCK, with $VERSION
200package Simple {
201 our $VERSION = '1.23';
202}
203---
204 '1.23' => <<'---', # package NAME VERSION BLOCK
205package Simple 1.23 {
206 1;
207}
208---
209 'v1.2.3_4' => <<'---', # package NAME VERSION BLOCK
210package Simple v1.2.3_4 {
211 1;
212}
213---
72a35bb9 214 '0' => <<'---', # set from separately-initialised variable
215package Simple;
216 our $CVSVERSION = '$Revision: 1.7 $';
217 our ($VERSION) = ($CVSVERSION =~ /(\d+\.\d+)/);
218}
219---
7a4e305a 220);
221my %modules = reverse @modules;
222
8e4bef01 223my @pkg_names = (
224 [ 'Simple' ] => <<'---', # package NAME
225package Simple;
226---
227 [ 'Simple::Edward' ] => <<'---', # package NAME::SUBNAME
228package Simple::Edward;
229---
230 [ 'Simple::Edward::' ] => <<'---', # package NAME::SUBNAME::
231package Simple::Edward::;
232---
233 [ "Simple'Edward" ] => <<'---', # package NAME'SUBNAME
234package Simple'Edward;
235---
236 [ "Simple'Edward::" ] => <<'---', # package NAME'SUBNAME::
237package Simple'Edward::;
238---
239 [ 'Simple::::Edward' ] => <<'---', # package NAME::::SUBNAME
240package Simple::::Edward;
241---
242 [ '::Simple::Edward' ] => <<'---', # package ::NAME::SUBNAME
243package ::Simple::Edward;
244---
245 [ 'main' ] => <<'---', # package NAME:SUBNAME (fail)
246package Simple:Edward;
247---
248 [ 'main' ] => <<'---', # package NAME' (fail)
249package Simple';
250---
251 [ 'main' ] => <<'---', # package NAME::SUBNAME' (fail)
252package Simple::Edward';
253---
254 [ 'main' ] => <<'---', # package NAME''SUBNAME (fail)
255package Simple''Edward;
256---
257 [ 'main' ] => <<'---', # package NAME-SUBNAME (fail)
258package Simple-Edward;
259---
260);
261my %pkg_names = reverse @pkg_names;
262
22553051 263plan tests => 63 + (2 * keys( %modules )) + (2 * keys( %pkg_names ));
7a4e305a 264
265require_ok('Module::Metadata');
266
1abfcc9a 267# class method C<find_module_by_name>
268my $module = Module::Metadata->find_module_by_name(
269 'Module::Metadata' );
270ok( -e $module, 'find_module_by_name() succeeds' );
271
272#########################
273
7a4e305a 274my $tmp = MBTest->tmpdir;
275
276use DistGen;
277my $dist = DistGen->new( dir => $tmp );
278$dist->regen;
279
280$dist->chdir_in;
281
7a4e305a 282
283# fail on invalid module name
284my $pm_info = Module::Metadata->new_from_module(
285 'Foo::Bar', inc => [] );
286ok( !defined( $pm_info ), 'fail if can\'t find module by module name' );
287
288
289# fail on invalid filename
290my $file = File::Spec->catfile( 'Foo', 'Bar.pm' );
291$pm_info = Module::Metadata->new_from_file( $file, inc => [] );
292ok( !defined( $pm_info ), 'fail if can\'t find module by file name' );
293
294
295# construct from module filename
296$file = File::Spec->catfile( 'lib', split( /::/, $dist->name ) ) . '.pm';
297$pm_info = Module::Metadata->new_from_file( $file );
298ok( defined( $pm_info ), 'new_from_file() succeeds' );
299
f33c0a6c 300# construct from filehandle
301my $handle = IO::File->new($file);
302$pm_info = Module::Metadata->new_from_handle( $handle, $file );
303ok( defined( $pm_info ), 'new_from_handle() succeeds' );
304$pm_info = Module::Metadata->new_from_handle( $handle );
305is( $pm_info, undef, "new_from_handle() without filename returns undef" );
02a3d478 306close($handle);
f33c0a6c 307
7a4e305a 308# construct from module name, using custom include path
309$pm_info = Module::Metadata->new_from_module(
310 $dist->name, inc => [ 'lib', @INC ] );
311ok( defined( $pm_info ), 'new_from_module() succeeds' );
312
313
314foreach my $module ( sort keys %modules ) {
315 my $expected = $modules{$module};
316 SKIP: {
317 skip( "No our() support until perl 5.6", 2 )
318 if $] < 5.006 && $module =~ /\bour\b/;
319 skip( "No package NAME VERSION support until perl 5.11.1", 2 )
320 if $] < 5.011001 && $module =~ /package\s+[\w\:\']+\s+v?[0-9._]+/;
321
322 $dist->change_file( 'lib/Simple.pm', $module );
323 $dist->regen;
324
325 my $warnings = '';
326 local $SIG{__WARN__} = sub { $warnings .= $_ for @_ };
327 my $pm_info = Module::Metadata->new_from_file( $file );
328
329 # Test::Builder will prematurely numify objects, so use this form
330 my $errs;
975132cb 331 my $got = $pm_info->version;
332 if ( defined $expected ) {
333 ok( $got eq $expected,
334 "correct module version (expected '$expected')" )
335 or $errs++;
336 } else {
337 ok( !defined($got),
338 "correct module version (expected undef)" )
339 or $errs++;
340 }
7a4e305a 341 is( $warnings, '', 'no warnings from parsing' ) or $errs++;
975132cb 342 diag "Got: '$got'\nModule contents:\n$module" if $errs;
7a4e305a 343 }
344}
345
346# revert to pristine state
8e4bef01 347$dist->regen( clean => 1 );
348
349foreach my $pkg_name ( sort keys %pkg_names ) {
350 my $expected = $pkg_names{$pkg_name};
351
352 $dist->change_file( 'lib/Simple.pm', $pkg_name );
353 $dist->regen;
354
355 my $warnings = '';
356 local $SIG{__WARN__} = sub { $warnings .= $_ for @_ };
357 my $pm_info = Module::Metadata->new_from_file( $file );
358
359 # Test::Builder will prematurely numify objects, so use this form
360 my $errs;
361 my @got = $pm_info->packages_inside();
362 is_deeply( \@got, $expected,
363 "correct package names (expected '" . join(', ', @$expected) . "')" )
364 or $errs++;
365 is( $warnings, '', 'no warnings from parsing' ) or $errs++;
366 diag "Got: '" . join(', ', @got) . "'\nModule contents:\n$pkg_name" if $errs;
367}
368
369# revert to pristine state
7a4e305a 370$dist->regen( clean => 1 );
371
372# Find each package only once
373$dist->change_file( 'lib/Simple.pm', <<'---' );
374package Simple;
375$VERSION = '1.23';
376package Error::Simple;
377$VERSION = '2.34';
378package Simple;
379---
380
381$dist->regen;
382
383$pm_info = Module::Metadata->new_from_file( $file );
384
385my @packages = $pm_info->packages_inside;
386is( @packages, 2, 'record only one occurence of each package' );
387
388
389# Module 'Simple.pm' does not contain package 'Simple';
390# constructor should not complain, no default module name or version
391$dist->change_file( 'lib/Simple.pm', <<'---' );
392package Simple::Not;
393$VERSION = '1.23';
394---
395
396$dist->regen;
397$pm_info = Module::Metadata->new_from_file( $file );
398
399is( $pm_info->name, undef, 'no default package' );
400is( $pm_info->version, undef, 'no version w/o default package' );
401
402# Module 'Simple.pm' contains an alpha version
403# constructor should report first $VERSION found
404$dist->change_file( 'lib/Simple.pm', <<'---' );
405package Simple;
406$VERSION = '1.23_01';
407$VERSION = eval $VERSION;
408---
409
410$dist->regen;
411$pm_info = Module::Metadata->new_from_file( $file );
412
413is( $pm_info->version, '1.23_01', 'alpha version reported');
414
415# NOTE the following test has be done this way because Test::Builder is
416# too smart for our own good and tries to see if the version object is a
417# dual-var, which breaks with alpha versions:
418# Argument "1.23_0100" isn't numeric in addition (+) at
419# /usr/lib/perl5/5.8.7/Test/Builder.pm line 505.
420
421ok( $pm_info->version > 1.23, 'alpha version greater than non');
422
423# revert to pristine state
424$dist->regen( clean => 1 );
425
426# parse $VERSION lines scripts for package main
427my @scripts = (
428 <<'---', # package main declared
429#!perl -w
430package main;
431$VERSION = '0.01';
432---
433 <<'---', # on first non-comment line, non declared package main
434#!perl -w
435$VERSION = '0.01';
436---
437 <<'---', # after non-comment line
438#!perl -w
439use strict;
440$VERSION = '0.01';
441---
442 <<'---', # 1st declared package
443#!perl -w
444package main;
445$VERSION = '0.01';
446package _private;
447$VERSION = '999';
448---
449 <<'---', # 2nd declared package
450#!perl -w
451package _private;
452$VERSION = '999';
453package main;
454$VERSION = '0.01';
455---
456 <<'---', # split package
457#!perl -w
458package main;
459package _private;
460$VERSION = '999';
461package main;
462$VERSION = '0.01';
463---
464 <<'---', # define 'main' version from other package
465package _private;
466$::VERSION = 0.01;
467$VERSION = '999';
468---
469 <<'---', # define 'main' version from other package
470package _private;
471$VERSION = '999';
472$::VERSION = 0.01;
473---
474);
475
476my ( $i, $n ) = ( 1, scalar( @scripts ) );
477foreach my $script ( @scripts ) {
478 $dist->change_file( 'bin/simple.plx', $script );
479 $dist->regen;
480 $pm_info = Module::Metadata->new_from_file(
481 File::Spec->catfile( 'bin', 'simple.plx' ) );
482
483 is( $pm_info->version, '0.01', "correct script version ($i of $n)" );
484 $i++;
485}
486
487
488# examine properties of a module: name, pod, etc
489$dist->change_file( 'lib/Simple.pm', <<'---' );
490package Simple;
491$VERSION = '0.01';
492package Simple::Ex;
493$VERSION = '0.02';
388bf282 494
7a4e305a 495=head1 NAME
496
497Simple - It's easy.
498
499=head1 AUTHOR
500
501Simple Simon
502
81ce8c82 503You can find me on the IRC channel
504#simon on irc.perl.org.
505
7a4e305a 506=cut
507---
508$dist->regen;
509
510$pm_info = Module::Metadata->new_from_module(
511 $dist->name, inc => [ 'lib', @INC ] );
512
513is( $pm_info->name, 'Simple', 'found default package' );
514is( $pm_info->version, '0.01', 'version for default package' );
515
516# got correct version for secondary package
517is( $pm_info->version( 'Simple::Ex' ), '0.02',
518 'version for secondary package' );
519
520my $filename = $pm_info->filename;
521ok( defined( $filename ) && -e $filename,
522 'filename() returns valid path to module file' );
523
524@packages = $pm_info->packages_inside;
525is( @packages, 2, 'found correct number of packages' );
526is( $packages[0], 'Simple', 'packages stored in order found' );
527
528# we can detect presence of pod regardless of whether we are collecting it
529ok( $pm_info->contains_pod, 'contains_pod() succeeds' );
530
531my @pod = $pm_info->pod_inside;
532is_deeply( \@pod, [qw(NAME AUTHOR)], 'found all pod sections' );
533
534is( $pm_info->pod('NONE') , undef,
535 'return undef() if pod section not present' );
536
537is( $pm_info->pod('NAME'), undef,
538 'return undef() if pod section not collected' );
539
540
541# collect_pod
542$pm_info = Module::Metadata->new_from_module(
543 $dist->name, inc => [ 'lib', @INC ], collect_pod => 1 );
544
617f8754 545{
546 my %pod;
547 for my $section (qw(NAME AUTHOR)) {
548 my $content = $pm_info->pod( $section );
549 if ( $content ) {
550 $content =~ s/^\s+//;
551 $content =~ s/\s+$//;
552 }
553 $pod{$section} = $content;
554 }
81ce8c82 555 my %expected = (
556 NAME => q|Simple - It's easy.|,
557 AUTHOR => <<'EXPECTED'
558Simple Simon
559
560You can find me on the IRC channel
561#simon on irc.perl.org.
562EXPECTED
563 );
564 for my $text (values %expected) {
565 $text =~ s/^\s+//;
566 $text =~ s/\s+$//;
567 }
568 is( $pod{NAME}, $expected{NAME}, 'collected NAME pod section' );
569 is( $pod{AUTHOR}, $expected{AUTHOR}, 'collected AUTHOR pod section' );
7a4e305a 570}
7a4e305a 571
572{
a4aafbc2 573 # test things that look like POD, but aren't
574$dist->change_file( 'lib/Simple.pm', <<'---' );
575package Simple;
a4aafbc2 576
cfedad89 577=YES THIS STARTS POD
578
579our $VERSION = '999';
a4aafbc2 580
a4aafbc2 581=cute
a4aafbc2 582
cfedad89 583our $VERSION = '666';
584
585=cut
586
587*foo
588=*no_this_does_not_start_pod;
589
590our $VERSION = '1.23';
a4aafbc2 591
592---
593 $dist->regen;
594 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
595 is( $pm_info->name, 'Simple', 'found default package' );
596 is( $pm_info->version, '1.23', 'version for default package' );
597}
598
599{
7a4e305a 600 # Make sure processing stops after __DATA__
601 $dist->change_file( 'lib/Simple.pm', <<'---' );
602package Simple;
603$VERSION = '0.01';
604__DATA__
605*UNIVERSAL::VERSION = sub {
606 foo();
607};
608---
609 $dist->regen;
610
611 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
612 is( $pm_info->name, 'Simple', 'found default package' );
613 is( $pm_info->version, '0.01', 'version for default package' );
614 my @packages = $pm_info->packages_inside;
615 is_deeply(\@packages, ['Simple'], 'packages inside');
616}
617
618{
619 # Make sure we handle version.pm $VERSIONs well
620 $dist->change_file( 'lib/Simple.pm', <<'---' );
621package Simple;
622$VERSION = version->new('0.60.' . (qw$Revision: 128 $)[1]);
623package Simple::Simon;
624$VERSION = version->new('0.61.' . (qw$Revision: 129 $)[1]);
625---
626 $dist->regen;
627
628 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
629 is( $pm_info->name, 'Simple', 'found default package' );
630 is( $pm_info->version, '0.60.128', 'version for default package' );
631 my @packages = $pm_info->packages_inside;
632 is_deeply([sort @packages], ['Simple', 'Simple::Simon'], 'packages inside');
633 is( $pm_info->version('Simple::Simon'), '0.61.129', 'version for embedded package' );
634}
635
388bf282 636# check that package_versions_from_directory works
637
638$dist->change_file( 'lib/Simple.pm', <<'---' );
639package Simple;
640$VERSION = '0.01';
641package Simple::Ex;
642$VERSION = '0.02';
643{
644 package main; # should ignore this
645}
646{
647 package DB; # should ignore this
648}
649{
650 package Simple::_private; # should ignore this
651}
652
653=head1 NAME
654
655Simple - It's easy.
656
657=head1 AUTHOR
658
659Simple Simon
660
661=cut
662---
663$dist->regen;
664
665my $exp_pvfd = {
666 'Simple' => {
667 'file' => 'Simple.pm',
668 'version' => '0.01'
669 },
670 'Simple::Ex' => {
671 'file' => 'Simple.pm',
672 'version' => '0.02'
673 }
674};
675
676my $got_pvfd = Module::Metadata->package_versions_from_directory('lib');
677
ca33f3bd 678is_deeply( $got_pvfd, $exp_pvfd, "package_version_from_directory()" )
388bf282 679 or diag explain $got_pvfd;
ca33f3bd 680
681{
c06d0187 682 my $got_provides = Module::Metadata->provides(dir => 'lib', version => 2);
ca33f3bd 683 my $exp_provides = {
684 'Simple' => {
685 'file' => 'lib/Simple.pm',
686 'version' => '0.01'
687 },
688 'Simple::Ex' => {
689 'file' => 'lib/Simple.pm',
690 'version' => '0.02'
691 }
692 };
693
694 is_deeply( $got_provides, $exp_provides, "provides()" )
695 or diag explain $got_provides;
696}
697
698{
c06d0187 699 my $got_provides = Module::Metadata->provides(dir => 'lib', prefix => 'other', version => 1.4);
ca33f3bd 700 my $exp_provides = {
701 'Simple' => {
702 'file' => 'other/Simple.pm',
703 'version' => '0.01'
704 },
705 'Simple::Ex' => {
706 'file' => 'other/Simple.pm',
707 'version' => '0.02'
708 }
709 };
710
711 is_deeply( $got_provides, $exp_provides, "provides()" )
712 or diag explain $got_provides;
713}
3c614865 714
715# Check package_versions_from_directory with regard to case-sensitivity
716{
717 $dist->change_file( 'lib/Simple.pm', <<'---' );
718package simple;
719$VERSION = '0.01';
720---
721 $dist->regen;
722
723 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
724 is( $pm_info->name, undef, 'no default package' );
725 is( $pm_info->version, undef, 'version for default package' );
726 is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
727 is( $pm_info->version('Simple'), undef, 'version for capitalized package' );
22553051 728 ok( $pm_info->is_indexable(), 'an indexable package is found' );
729 ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
730 ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
3c614865 731
732 $dist->change_file( 'lib/Simple.pm', <<'---' );
733package simple;
734$VERSION = '0.01';
735package Simple;
736$VERSION = '0.02';
737package SiMpLe;
738$VERSION = '0.03';
739---
740 $dist->regen;
741
742 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
743 is( $pm_info->name, 'Simple', 'found default package' );
744 is( $pm_info->version, '0.02', 'version for default package' );
745 is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
746 is( $pm_info->version('Simple'), '0.02', 'version for capitalized package' );
747 is( $pm_info->version('SiMpLe'), '0.03', 'version for mixed-case package' );
22553051 748 ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
749 ok( $pm_info->is_indexable('Simple'), 'the Simple package is indexable' );
750
751 $dist->change_file( 'lib/Simple.pm', <<'---' );
752package ## hide from PAUSE
753 simple;
754$VERSION = '0.01';
755---
756
757 $dist->regen;
758
759 $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
760 is( $pm_info->name, undef, 'no package names found' );
761 ok( !$pm_info->is_indexable('simple'), 'the simple package would not be indexed' );
762 ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
763 ok( !$pm_info->is_indexable(), 'no indexable package is found' );
3c614865 764}