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