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