Bring Pod::Simple up to 3.09 as on CPAN.
[p5sagit/p5-mst-13.2.git] / cpan / Pod-Simple / t / search50.t
CommitLineData
351625bd 1BEGIN {
2 if( $ENV{PERL_CORE} ) {
3 chdir 't';
4 use File::Spec;
5 @INC = (File::Spec->rel2abs('../lib') );
6 }
7}
8use strict;
9
10#sub Pod::Simple::Search::DEBUG () {5};
11
12use Pod::Simple::Search;
13use Test;
9d65762f 14BEGIN { plan tests => 8 }
351625bd 15
16print "# Test the scanning of the whole of \@INC ...\n";
17
18my $x = Pod::Simple::Search->new;
19die "Couldn't make an object!?" unless ok defined $x;
20ok $x->inc; # make sure inc=1 is the default
21print $x->_state_as_string;
22#$x->verbose(12);
23
24use Pod::Simple;
25*pretty = \&Pod::Simple::BlackBox::pretty;
26
27my $found = 0;
28$x->callback(sub {
29 print "# ", join(" ", map "{$_}", @_), "\n";
30 ++$found;
31 return;
32});
33
34print "# \@INC == @INC\n";
35
36my $t = time(); my($name2where, $where2name) = $x->survey();
37$t = time() - $t;
38ok $found;
39
40print "# Found $found items in $t seconds!\n# See...\n";
41
42my $p = pretty( $where2name, $name2where )."\n";
43$p =~ s/, +/,\n/g;
44$p =~ s/^/# /mg;
45print $p;
46
47print "# OK, making sure strict and strict.pm were in there...\n";
9d65762f 48print "# (On Debian-based distributions Pod is stripped from\n",
49 "# strict.pm, so skip these tests.)\n";
50my $nopod = not exists ($name2where->{'strict'});
51skip($nopod, ($name2where->{'strict'} || 'huh???'), '/strict\.(pod|pm)$/');
351625bd 52
9d65762f 53skip($nopod, grep( m/strict\.(pod|pm)/, keys %$where2name ));
351625bd 54
55my $strictpath = $name2where->{'strict'};
56if( $strictpath ) {
57 my @x = ($x->find('strict')||'(nil)', $strictpath);
58 print "# Comparing \"$x[0]\" to \"$x[1]\"\n";
59 for(@x) { s{[/\\]}{/}g; }
60 print "# => \"$x[0]\" to \"$x[1]\"\n";
61 ok $x[0], $x[1], " find('strict') should match survey's name2where{strict}";
9d65762f 62} elsif ($nopod) {
63 skip "skipping find() for strict.pm"; # skipping find() for 'thatpath/strict.pm
351625bd 64} else {
9d65762f 65 ok 0; # an entry without a defined path means can't test find()
66}
67
68print "# Test again on a module we know is present, in case the
69strict.pm tests were skipped...\n";
70
71# Grab the first item in $name2where, since it doesn't matter which we
72# use.
73my $testmod = (keys %$name2where)[0];
74my $testpath = $name2where->{$testmod};
75if( $testmod ) {
76 my @x = ($x->find($testmod)||'(nil)', $testpath);
77 print "# Comparing \"$x[0]\" to \"$x[1]\"\n";
78 for(@x) { s{[/\\]}{/}g; }
79 print "# => \"$x[0]\" to \"$x[1]\"\n";
80 ok $x[0], $x[1], " find('$testmod') should match survey's name2where{$testmod}";
81} else {
82 ok 0; # no 'thatpath/<name>.pm' means can't test find()
351625bd 83}
84
85ok 1;
86print "# Byebye from ", __FILE__, "\n";
87print "# @INC\n";
88__END__
89