xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/search20.t (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
1b39c5158Smillertuse strict;
2eac174f2Safresh1use warnings;
3b39c5158Smillertuse Pod::Simple::Search;
4*3d61058aSafresh1use Test::More tests => 9;
5b39c5158Smillert
6b39c5158Smillertprint "# ", __FILE__,
7b39c5158Smillert ": Testing the scanning of several (well, two) docroots...\n";
8b39c5158Smillert
9b39c5158Smillertmy $x = Pod::Simple::Search->new;
10b39c5158Smillertdie "Couldn't make an object!?" unless ok defined $x;
11b39c5158Smillert
12b39c5158Smillert$x->inc(0);
13b39c5158Smillert
14b39c5158Smillert$x->callback(sub {
15b39c5158Smillert  print "#  ", join("  ", map "{$_}", @_), "\n";
16b39c5158Smillert  return;
17b39c5158Smillert});
18b39c5158Smillert
19b39c5158Smillertuse File::Spec;
20*3d61058aSafresh1use Cwd ();
21*3d61058aSafresh1use File::Basename ();
22b39c5158Smillert
23*3d61058aSafresh1my $t_dir = File::Basename::dirname(Cwd::abs_path(__FILE__));
24b39c5158Smillert
25*3d61058aSafresh1my $here1 = File::Spec->catdir($t_dir, 'testlib1');
26*3d61058aSafresh1my $here2 = File::Spec->catdir($t_dir, 'testlib2');
27*3d61058aSafresh1
28b39c5158Smillertprint "# OK, found the test corpora\n#  as $here1\n# and $here2\n";
29b39c5158Smillert
30b39c5158Smillertprint $x->_state_as_string;
31b39c5158Smillert#$x->verbose(12);
32b39c5158Smillert
33b39c5158Smillertuse Pod::Simple;
34b39c5158Smillert*pretty = \&Pod::Simple::BlackBox::pretty;
35b39c5158Smillert
36b39c5158Smillertprint "# OK, starting run...\n# [[\n";
37b39c5158Smillertmy($name2where, $where2name) = $x->survey($here1, $here2);
38b39c5158Smillertprint "# ]]\n#OK, run done.\n";
39b39c5158Smillert
40b39c5158Smillertmy $p = pretty( $where2name, $name2where )."\n";
41b39c5158Smillert$p =~ s/, +/,\n/g;
42b39c5158Smillert$p =~ s/^/#  /mg;
43b39c5158Smillertprint $p;
44b39c5158Smillert
45*3d61058aSafresh1require File::Spec->catfile($t_dir, 'ascii_order.pl');
46b8851fccSafresh1
47*3d61058aSafresh1SKIP: {
48*3d61058aSafresh1    skip '-- case may or may not be preserved', 2
49*3d61058aSafresh1        if $^O eq 'VMS';
50b8851fccSafresh1
51b39c5158Smillert    {
52b8851fccSafresh1        my $names = join "|", sort ascii_order values %$where2name;
53*3d61058aSafresh1        is $names,
5456d68f1eSafresh1            "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
55b39c5158Smillert    }
56b39c5158Smillert
57b39c5158Smillert    {
58b8851fccSafresh1        my $names = join "|", sort ascii_order keys %$name2where;
59*3d61058aSafresh1        is $names,
6056d68f1eSafresh1            "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
61b39c5158Smillert    }
62*3d61058aSafresh1}
63b39c5158Smillert
64*3d61058aSafresh1like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
65b39c5158Smillert
66*3d61058aSafresh1is grep( m/squaa\.pm/, keys %$where2name ), 1;
67b39c5158Smillert
68898184e3Ssthen###### Now with recurse(0)
69898184e3Ssthen
70898184e3Ssthen$x->recurse(0);
71898184e3Ssthen
72898184e3Ssthenprint "# OK, starting run without recurse...\n# [[\n";
73898184e3Ssthen($name2where, $where2name) = $x->survey($here1, $here2);
74898184e3Ssthenprint "# ]]\n#OK, run without recurse done.\n";
75898184e3Ssthen
76898184e3Ssthen$p = pretty( $where2name, $name2where )."\n";
77898184e3Ssthen$p =~ s/, +/,\n/g;
78898184e3Ssthen$p =~ s/^/#  /mg;
79898184e3Ssthenprint $p;
80898184e3Ssthen
81*3d61058aSafresh1SKIP: {
82*3d61058aSafresh1    skip '-- case may or may not be preserved', 2
83*3d61058aSafresh1        if $^O eq 'VMS';
84*3d61058aSafresh1
85898184e3Ssthen    {
86b8851fccSafresh1        my $names = join "|", sort ascii_order values %$where2name;
87*3d61058aSafresh1        is $names,
88898184e3Ssthen            "Blorm|Suzzle|squaa|zikzik";
89898184e3Ssthen    }
90898184e3Ssthen
91898184e3Ssthen    {
92b8851fccSafresh1        my $names = join "|", sort ascii_order keys %$name2where;
93*3d61058aSafresh1        is $names,
94898184e3Ssthen            "Blorm|Suzzle|squaa|zikzik";
95898184e3Ssthen    }
96*3d61058aSafresh1}
97898184e3Ssthen
98*3d61058aSafresh1like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
99898184e3Ssthen
100*3d61058aSafresh1is grep( m/squaa\.pm/, keys %$where2name ), 1;
101