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 => 5 } |
12 | |
13 | |
14 | # |
15 | # "kleene" rhymes with "zany". It's a fact! |
16 | # |
17 | |
18 | |
19 | print "# ", __FILE__, |
20 | ": Testing limit_glob ...\n"; |
21 | |
22 | my $x = Pod::Simple::Search->new; |
23 | die "Couldn't make an object!?" unless ok defined $x; |
24 | |
25 | $x->inc(0); |
26 | $x->shadows(1); |
27 | |
28 | use File::Spec; |
29 | use Cwd; |
30 | my $cwd = cwd(); |
31 | print "# CWD: $cwd\n"; |
32 | |
33 | sub source_path { |
34 | my $file = shift; |
35 | if ($ENV{PERL_CORE}) { |
36 | my $updir = File::Spec->updir; |
37 | my $dir = File::Spec->catdir($updir, 'lib', 'Pod', 'Simple', 't'); |
38 | return File::Spec->catdir ($dir, $file); |
39 | } else { |
40 | return $file; |
41 | } |
42 | } |
43 | |
44 | my($here1, $here2, $here3); |
45 | |
318efef0 |
46 | if( -e ($here1 = source_path( 'test_lib' ))) { |
351625bd |
47 | die "But where's $here2?" |
318efef0 |
48 | unless -e ($here2 = source_path ( 'other_test_lib')); |
351625bd |
49 | die "But where's $here3?" |
318efef0 |
50 | unless -e ($here3 = source_path( 'yet_another_test_lib')); |
351625bd |
51 | |
318efef0 |
52 | } elsif( -e ($here1 = File::Spec->catdir($cwd, 't', 'test_lib' ))) { |
351625bd |
53 | die "But where's $here2?" |
318efef0 |
54 | unless -e ($here2 = File::Spec->catdir($cwd, 't', 'other_test_lib')); |
351625bd |
55 | die "But where's $here3?" |
318efef0 |
56 | unless -e ($here3 = File::Spec->catdir($cwd, 't', 'yet_another_test_lib')); |
351625bd |
57 | |
58 | } else { |
59 | die "Can't find the test corpora"; |
60 | } |
61 | print "# OK, found the test corpora\n# as $here1\n# and $here2\n# and $here3\n#\n"; |
62 | ok 1; |
63 | |
64 | print $x->_state_as_string; |
65 | #$x->verbose(12); |
66 | |
67 | use Pod::Simple; |
68 | *pretty = \&Pod::Simple::BlackBox::pretty; |
69 | |
70 | my $glob = '*k'; |
71 | print "# Limiting to $glob\n"; |
72 | $x->limit_glob($glob); |
73 | |
74 | my($name2where, $where2name) = $x->survey($here1, $here2, $here3); |
75 | |
76 | my $p = pretty( $where2name, $name2where )."\n"; |
77 | $p =~ s/, +/,\n/g; |
78 | $p =~ s/^/# /mg; |
79 | print $p; |
80 | |
81 | { |
82 | my $names = join "|", sort keys %$name2where; |
318efef0 |
83 | ok $names, "Zonk::Pronk|hink_honk::Glunk|perlzuk|squaa::Glunk|zikzik"; |
351625bd |
84 | } |
85 | |
86 | { |
87 | my $names = join "|", sort values %$where2name; |
318efef0 |
88 | ok $names, "Zonk::Pronk|hink_honk::Glunk|hink_honk::Glunk|perlzuk|squaa::Glunk|zikzik"; |
351625bd |
89 | } |
90 | |
91 | print "# OK, bye from ", __FILE__, "\n"; |
92 | ok 1; |
93 | |
94 | __END__ |
95 | |