d2072768578762c473ef0794f626b3defd798c08
[p5sagit/p5-mst-13.2.git] / lib / Pod / Simple / t / search_50survey_inc.t
1 BEGIN {
2     if( $ENV{PERL_CORE} ) {
3         chdir 't';
4         use File::Spec;
5         @INC = (File::Spec->rel2abs('../lib') );
6     }
7 }
8 use strict;
9
10 #sub Pod::Simple::Search::DEBUG () {5};
11
12 use Pod::Simple::Search;
13 use Test;
14 BEGIN { plan tests => 7 }
15
16 print "#  Test the scanning of the whole of \@INC ...\n";
17
18 my $x = Pod::Simple::Search->new;
19 die "Couldn't make an object!?" unless ok defined $x;
20 ok $x->inc; # make sure inc=1 is the default
21 print $x->_state_as_string;
22 #$x->verbose(12);
23
24 use Pod::Simple;
25 *pretty = \&Pod::Simple::BlackBox::pretty;
26
27 my $found = 0;
28 $x->callback(sub {
29   print "#  ", join("  ", map "{$_}", @_), "\n";
30   ++$found;
31   return;
32 });
33
34 print "# \@INC == @INC\n";
35
36 my $t = time();   my($name2where, $where2name) = $x->survey();
37 $t = time() - $t;
38 ok $found;
39
40 print "# Found $found items in $t seconds!\n# See...\n";
41
42 my $p = pretty( $where2name, $name2where )."\n";
43 $p =~ s/, +/,\n/g;
44 $p =~ s/^/#  /mg;
45 print $p;
46
47 print "# OK, making sure strict and strict.pm were in there...\n";
48 ok( ($name2where->{'strict'} || 'huh???'), '/strict\.(pod|pm)$/');
49
50 ok grep( m/strict\.(pod|pm)/, keys %$where2name );
51
52 my  $strictpath = $name2where->{'strict'};
53 if( $strictpath ) {
54   my @x = ($x->find('strict')||'(nil)', $strictpath);
55   print "# Comparing \"$x[0]\" to \"$x[1]\"\n";
56   for(@x) { s{[/\\]}{/}g; }
57   print "#        => \"$x[0]\" to \"$x[1]\"\n";
58   ok $x[0], $x[1], " find('strict') should match survey's name2where{strict}";
59 } else {
60   ok 0;  # no 'thatpath/strict.pm' means can't test find()
61 }
62
63 ok 1;
64 print "# Byebye from ", __FILE__, "\n";
65 print "# @INC\n";
66 __END__
67