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