This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Pod-Simple to CPAN version 3.18
[perl5.git] / cpan / Pod-Simple / t / search26.t
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
46 if(        -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 }
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;
83 ok $names, "Zonk::Pronk|hinkhonk::Glunk|perlzuk|squaa::Glunk|zikzik";
84 }
85
86 {
87 my $names = join "|", sort values %$where2name;
88 ok $names, "Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Glunk|perlzuk|squaa::Glunk|zikzik";
89 }
90
91 print "# OK, bye from ", __FILE__, "\n";
92 ok 1;
93
94 __END__
95