1b39c5158Smillertuse strict; 2eac174f2Safresh1use warnings; 3*3d61058aSafresh1use Test::More tests => 13; 4*3d61058aSafresh1 5b39c5158Smillertuse Pod::Simple::Search; 6b39c5158Smillert 7b39c5158Smillertprint "# ", __FILE__, 8b39c5158Smillert ": Testing the scanning of several docroots...\n"; 9b39c5158Smillert 10b39c5158Smillertmy $x = Pod::Simple::Search->new; 11b39c5158Smillertdie "Couldn't make an object!?" unless ok defined $x; 12b39c5158Smillert 13b39c5158Smillert$x->inc(0); 14b39c5158Smillert$x->shadows(1); 15b39c5158Smillert 16b39c5158Smillertuse File::Spec; 17*3d61058aSafresh1use Cwd (); 18*3d61058aSafresh1use File::Basename (); 19b39c5158Smillert 20*3d61058aSafresh1my $t_dir = File::Basename::dirname(Cwd::abs_path(__FILE__)); 21b39c5158Smillert 22*3d61058aSafresh1my $here1 = File::Spec->catdir($t_dir, 'testlib1'); 23*3d61058aSafresh1my $here2 = File::Spec->catdir($t_dir, 'testlib2'); 24*3d61058aSafresh1my $here3 = File::Spec->catdir($t_dir, 'testlib3'); 25b39c5158Smillert 26b39c5158Smillertprint "# OK, found the test corpora\n# as $here1\n# and $here2\n# and $here3\n#\n"; 27b39c5158Smillert 28b39c5158Smillertprint $x->_state_as_string; 29b39c5158Smillert#$x->verbose(12); 30b39c5158Smillert 31b39c5158Smillertuse Pod::Simple; 32b39c5158Smillert*pretty = \&Pod::Simple::BlackBox::pretty; 33b39c5158Smillert 34b39c5158Smillertmy($name2where, $where2name) = $x->survey($here1, $here2, $here3); 35b39c5158Smillert 36b39c5158Smillertmy $p = pretty( $where2name, $name2where )."\n"; 37b39c5158Smillert$p =~ s/, +/,\n/g; 38b39c5158Smillert$p =~ s/^/# /mg; 39b39c5158Smillertprint $p; 40b39c5158Smillert 41*3d61058aSafresh1require File::Spec->catfile($t_dir, 'ascii_order.pl'); 42b8851fccSafresh1 43*3d61058aSafresh1SKIP: { 44*3d61058aSafresh1 skip '-- case may or may not be preserved', 2 45*3d61058aSafresh1 if $^O eq 'VMS'; 46b8851fccSafresh1 47b39c5158Smillert { 48b39c5158Smillert print "# won't show any shadows, since we're just looking at the name2where keys\n"; 49b8851fccSafresh1 my $names = join "|", sort ascii_order keys %$name2where; 50*3d61058aSafresh1 51*3d61058aSafresh1 is $names, 5256d68f1eSafresh1 "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik"; 53b39c5158Smillert } 54b39c5158Smillert 55b39c5158Smillert { 56b39c5158Smillert print "# but here we'll see shadowing:\n"; 57b8851fccSafresh1 my $names = join "|", sort ascii_order values %$where2name; 58*3d61058aSafresh1 is $names, 5956d68f1eSafresh1 "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Glunk|hinkhonk::Vliff|hinkhonk::Vliff|perlflif|perlthng|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Vliff|squaa::Vliff|squaa::Wowo|zikzik"; 60*3d61058aSafresh1 } 61*3d61058aSafresh1} 62b39c5158Smillert 63*3d61058aSafresh1{ 64b39c5158Smillertmy %count; 65b39c5158Smillertfor(values %$where2name) { ++$count{$_} }; 66b39c5158Smillert#print pretty(\%count), "\n\n"; 67b39c5158Smillertdelete @count{ grep $count{$_} < 2, keys %count }; 68b8851fccSafresh1my $shadowed = join "|", sort ascii_order keys %count; 69*3d61058aSafresh1is $shadowed, "hinkhonk::Glunk|hinkhonk::Vliff|perlthng|squaa::Vliff"; 70b39c5158Smillert 71b8851fccSafresh1sub thar { print "# Seen $_[0] :\n", map "# {$_}\n", sort ascii_order grep $where2name->{$_} eq $_[0],keys %$where2name; return; } 72b39c5158Smillert 73*3d61058aSafresh1is $count{'perlthng'}, 2; 74b39c5158Smillertthar 'perlthng'; 75*3d61058aSafresh1is $count{'squaa::Vliff'}, 3; 76b39c5158Smillertthar 'squaa::Vliff'; 77b39c5158Smillert} 78b39c5158Smillert 79b39c5158Smillert 80*3d61058aSafresh1like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/); 81b39c5158Smillert 82*3d61058aSafresh1is grep( m/squaa\.pm/, keys %$where2name ), 1; 83b39c5158Smillert 84*3d61058aSafresh1like( ($name2where->{'perlthng'} || 'huh???'), qr/[^\^]testlib1/ ); 85*3d61058aSafresh1like( ($name2where->{'squaa::Vliff'} || 'huh???'), qr/[^\^]testlib1/ ); 86*3d61058aSafresh1 87*3d61058aSafresh1SKIP: { 88*3d61058aSafresh1 skip '-- case may or may not be preserved', 1 89*3d61058aSafresh1 if $^O eq 'VMS'; 90b39c5158Smillert 91b39c5158Smillert # Some sanity: 92*3d61058aSafresh1 like 93*3d61058aSafresh1 +($name2where->{'squaa::Wowo'} || 'huh???'), 94*3d61058aSafresh1 qr/testlib2/; 95*3d61058aSafresh1} 96b39c5158Smillert 9756d68f1eSafresh1my $in_pods = $x->find('perlzoned', $here2); 98*3d61058aSafresh1like $in_pods, qr{^\Q$here2\E}; 99*3d61058aSafresh1like $in_pods, qr{perlzoned.pod$}; 100