1use strict;
2use warnings;
3use Test::More tests => 9;
4
5#sub Pod::Simple::Search::DEBUG () {5};
6
7use Pod::Simple::Search;
8
9print "# ", __FILE__,
10 ": Testing the surveying of a single specified docroot...\n";
11
12my $x = Pod::Simple::Search->new;
13die "Couldn't make an object!?" unless ok defined $x;
14
15$x->inc(0);
16
17use File::Spec;
18use Cwd ();
19use File::Basename ();
20
21my $t_dir = File::Basename::dirname(Cwd::abs_path(__FILE__));
22
23my $here = File::Spec->catdir($t_dir, 'testlib1');
24
25print "# OK, found the test corpus as $here\n";
26
27print $x->_state_as_string;
28#$x->verbose(12);
29
30use Pod::Simple;
31*pretty = \&Pod::Simple::BlackBox::pretty;
32
33my($name2where, $where2name) = $x->survey($here);
34
35my $p = pretty( $where2name, $name2where )."\n";
36$p =~ s/, +/,\n/g;
37$p =~ s/^/#  /mg;
38print $p;
39
40require File::Spec->catfile($t_dir, 'ascii_order.pl');
41
42{
43my $names = join "|", sort ascii_order values %$where2name;
44is $names, "Blorm|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|squaa|squaa::Glunk|squaa::Vliff|zikzik";
45}
46
47{
48my $names = join "|", sort ascii_order keys %$name2where;
49is $names, "Blorm|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|squaa|squaa::Glunk|squaa::Vliff|zikzik";
50}
51
52like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
53
54is grep( m/squaa\.pm/, keys %$where2name ), 1;
55
56###### Now with recurse(0)
57
58print "# Testing the surveying of a single docroot without recursing...\n";
59
60$x->recurse(0);
61($name2where, $where2name) = $x->survey($here);
62
63$p = pretty( $where2name, $name2where )."\n";
64$p =~ s/, +/,\n/g;
65$p =~ s/^/#  /mg;
66print $p;
67
68{
69my $names = join "|", sort ascii_order values %$where2name;
70is $names, "Blorm|squaa|zikzik";
71}
72
73{
74my $names = join "|", sort ascii_order keys %$name2where;
75is $names, "Blorm|squaa|zikzik";
76}
77
78like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
79
80is grep( m/squaa\.pm/, keys %$where2name ), 1;
81