Additional test file edits needed for Pod-Simple-3.05 that couldn't
[p5sagit/p5-mst-13.2.git] / lib / Pod / Simple / t / search22.t
CommitLineData
351625bd 1BEGIN {
2 if($ENV{PERL_CORE}) {
3 chdir 't';
4 @INC = '../lib';
5 }
6}
7
8use strict;
9use Pod::Simple::Search;
10use Test;
11BEGIN { plan tests => 13 }
12
13print "# ", __FILE__,
14 ": Testing the scanning of several docroots...\n";
15
16my $x = Pod::Simple::Search->new;
17die "Couldn't make an object!?" unless ok defined $x;
18
19$x->inc(0);
20$x->shadows(1);
21
22use File::Spec;
23use Cwd;
24my $cwd = cwd();
25print "# CWD: $cwd\n";
26
27sub source_path {
28 my $file = shift;
29 if ($ENV{PERL_CORE}) {
30 my $updir = File::Spec->updir;
31 my $dir = File::Spec->catdir($updir, 'lib', 'Pod', 'Simple', 't');
32 return File::Spec->catdir ($dir, $file);
33 } else {
34 return $file;
35 }
36}
37
38my($here1, $here2, $here3);
39
9b134129 40if( -e ($here1 = source_path('testlib1' ))) {
351625bd 41 die "But where's $here2?"
9b134129 42 unless -e ($here2 = source_path('testlib2'));
351625bd 43 die "But where's $here3?"
9b134129 44 unless -e ($here3 = source_path('testlib3'));
351625bd 45
9b134129 46} elsif( -e ($here1 = File::Spec->catdir($cwd, 't', 'testlib1' ))) {
351625bd 47 die "But where's $here2?"
9b134129 48 unless -e ($here2 = File::Spec->catdir($cwd, 't', 'testlib2'));
351625bd 49 die "But where's $here3?"
9b134129 50 unless -e ($here3 = File::Spec->catdir($cwd, 't', 'testlib3'));
351625bd 51
52} else {
53 die "Can't find the test corpora";
54}
55print "# OK, found the test corpora\n# as $here1\n# and $here2\n# and $here3\n#\n";
56ok 1;
57
58print $x->_state_as_string;
59#$x->verbose(12);
60
61use Pod::Simple;
62*pretty = \&Pod::Simple::BlackBox::pretty;
63
64my($name2where, $where2name) = $x->survey($here1, $here2, $here3);
65
66my $p = pretty( $where2name, $name2where )."\n";
67$p =~ s/, +/,\n/g;
68$p =~ s/^/# /mg;
69print $p;
70
71{
72print "# won't show any shadows, since we're just looking at the name2where keys\n";
73my $names = join "|", sort keys %$name2where;
9b134129 74ok $names, "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
351625bd 75}
76
77{
78print "# but here we'll see shadowing:\n";
79my $names = join "|", sort values %$where2name;
9b134129 80ok $names, "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Glunk|hinkhonk::Vliff|hinkhonk::Vliff|perlflif|perlthng|perlthng|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Vliff|squaa::Vliff|squaa::Wowo|zikzik";
351625bd 81
82my %count;
83for(values %$where2name) { ++$count{$_} };
84#print pretty(\%count), "\n\n";
85delete @count{ grep $count{$_} < 2, keys %count };
86my $shadowed = join "|", sort keys %count;
9b134129 87ok $shadowed, "hinkhonk::Glunk|hinkhonk::Vliff|perlthng|squaa::Vliff";
351625bd 88
89sub thar { print "# Seen $_[0] :\n", map "# {$_}\n", sort grep $where2name->{$_} eq $_[0],keys %$where2name; return; }
90
9b134129 91ok $count{'perlthng'}, 2;
92thar 'perlthng';
351625bd 93ok $count{'squaa::Vliff'}, 3;
94thar 'squaa::Vliff';
95}
96
97
98ok( ($name2where->{'squaa'} || 'huh???'), '/squaa\.pm$/');
99
100ok grep( m/squaa\.pm/, keys %$where2name ), 1;
101
9b134129 102ok( ($name2where->{'perlthng'} || 'huh???'), '/[^\^]testlib1/' );
103ok( ($name2where->{'squaa::Vliff'} || 'huh???'), '/[^\^]testlib1/' );
351625bd 104
105# Some sanity:
9b134129 106ok( ($name2where->{'squaa::Wowo'} || 'huh???'), '/testlib2/' );
351625bd 107
108
109
110
111print "# OK, bye from ", __FILE__, "\n";
112ok 1;
113
114__END__
115