Commit | Line | Data |
351625bd |
1 | BEGIN { |
2 | if($ENV{PERL_CORE}) { |
3 | chdir 't'; |
4 | @INC = '../lib'; |
5 | } |
6 | } |
7 | |
8 | use strict; |
9 | use Pod::Simple::Search; |
10 | use Test; |
11 | BEGIN { plan tests => 10 } |
12 | |
13 | print "# ", __FILE__, |
14 | ": Testing limit_glob ...\n"; |
15 | |
16 | my $x = Pod::Simple::Search->new; |
17 | die "Couldn't make an object!?" unless ok defined $x; |
18 | |
19 | $x->inc(0); |
20 | $x->shadows(1); |
21 | |
22 | use File::Spec; |
23 | use Cwd; |
24 | my $cwd = cwd(); |
25 | print "# CWD: $cwd\n"; |
26 | |
27 | sub 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 | |
38 | my($here1, $here2, $here3); |
39 | |
9b134129 |
40 | if( -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 | } |
55 | print "# OK, found the test corpora\n# as $here1\n# and $here2\n# and $here3\n#\n"; |
56 | ok 1; |
57 | |
58 | print $x->_state_as_string; |
59 | #$x->verbose(12); |
60 | |
61 | use Pod::Simple; |
62 | *pretty = \&Pod::Simple::BlackBox::pretty; |
63 | |
64 | my $glob = 'squaa*'; |
65 | print "# Limiting to $glob\n"; |
66 | $x->limit_glob($glob); |
67 | |
68 | my($name2where, $where2name) = $x->survey($here1, $here2, $here3); |
69 | |
70 | my $p = pretty( $where2name, $name2where )."\n"; |
71 | $p =~ s/, +/,\n/g; |
72 | $p =~ s/^/# /mg; |
73 | print $p; |
74 | |
75 | { |
76 | my $names = join "|", sort keys %$name2where; |
77 | ok $names, "squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo"; |
78 | } |
79 | |
80 | { |
81 | my $names = join "|", sort values %$where2name; |
82 | ok $names, "squaa|squaa::Glunk|squaa::Vliff|squaa::Vliff|squaa::Vliff|squaa::Wowo"; |
83 | |
84 | my %count; |
85 | for(values %$where2name) { ++$count{$_} }; |
86 | #print pretty(\%count), "\n\n"; |
87 | delete @count{ grep $count{$_} < 2, keys %count }; |
88 | my $shadowed = join "|", sort keys %count; |
89 | ok $shadowed, "squaa::Vliff"; |
90 | |
91 | sub thar { print "# Seen $_[0] :\n", map "# {$_}\n", sort grep $where2name->{$_} eq $_[0],keys %$where2name; return; } |
92 | |
93 | ok $count{'squaa::Vliff'}, 3; |
94 | thar 'squaa::Vliff'; |
95 | } |
96 | |
97 | |
98 | ok $name2where->{'squaa'}; # because squaa.pm IS squaa* |
99 | |
9b134129 |
100 | ok( ($name2where->{'squaa::Vliff'} || 'huh???'), '/[^\^]testlib1/' ); |
351625bd |
101 | |
9b134129 |
102 | ok( ($name2where->{'squaa::Wowo'} || 'huh???'), '/testlib2/' ); |
351625bd |
103 | |
104 | |
105 | print "# OK, bye from ", __FILE__, "\n"; |
106 | ok 1; |
107 | |
108 | __END__ |
109 | |