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 => 10 } 12 13print "# ", __FILE__, 14 ": Testing limit_glob ...\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 40if( -e ($here1 = source_path( 'testlib1' ))) { 41 die "But where's $here2?" 42 unless -e ($here2 = source_path( 'testlib2')); 43 die "But where's $here3?" 44 unless -e ($here3 = source_path( 'testlib3')); 45 46} elsif( -e ($here1 = File::Spec->catdir($cwd, 't', 'testlib1' ))) { 47 die "But where's $here2?" 48 unless -e ($here2 = File::Spec->catdir($cwd, 't', 'testlib2')); 49 die "But where's $here3?" 50 unless -e ($here3 = File::Spec->catdir($cwd, 't', 'testlib3')); 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 $glob = 'squaa*'; 65print "# Limiting to $glob\n"; 66$x->limit_glob($glob); 67 68my($name2where, $where2name) = $x->survey($here1, $here2, $here3); 69 70my $p = pretty( $where2name, $name2where )."\n"; 71$p =~ s/, +/,\n/g; 72$p =~ s/^/# /mg; 73print $p; 74 75{ 76my $names = join "|", sort keys %$name2where; 77skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 78 $names, 79 "squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo"; 80} 81 82{ 83my $names = join "|", sort values %$where2name; 84skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 85 $names, 86 "squaa|squaa::Glunk|squaa::Vliff|squaa::Vliff|squaa::Vliff|squaa::Wowo"; 87 88my %count; 89for(values %$where2name) { ++$count{$_} }; 90#print pretty(\%count), "\n\n"; 91delete @count{ grep $count{$_} < 2, keys %count }; 92my $shadowed = join "|", sort keys %count; 93ok $shadowed, "squaa::Vliff"; 94 95sub thar { print "# Seen $_[0] :\n", map "# {$_}\n", sort grep $where2name->{$_} eq $_[0],keys %$where2name; return; } 96 97ok $count{'squaa::Vliff'}, 3; 98thar 'squaa::Vliff'; 99} 100 101 102ok $name2where->{'squaa'}; # because squaa.pm IS squaa* 103 104ok( ($name2where->{'squaa::Vliff'} || 'huh???'), '/[^\^]testlib1/' ); 105 106skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 107 ($name2where->{'squaa::Wowo'} || 'huh???'), 108 '/testlib2/'; 109 110 111print "# OK, bye from ", __FILE__, "\n"; 112ok 1; 113 114__END__ 115 116