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