1use strict;
2use warnings;
3use Pod::Simple::Search;
4use Test::More tests => 9;
5
6print "# ", __FILE__,
7 ": Testing the scanning of several (well, two) docroots...\n";
8
9my $x = Pod::Simple::Search->new;
10die "Couldn't make an object!?" unless ok defined $x;
11
12$x->inc(0);
13
14$x->callback(sub {
15  print "#  ", join("  ", map "{$_}", @_), "\n";
16  return;
17});
18
19use File::Spec;
20use Cwd ();
21use File::Basename ();
22
23my $t_dir = File::Basename::dirname(Cwd::abs_path(__FILE__));
24
25my $here1 = File::Spec->catdir($t_dir, 'testlib1');
26my $here2 = File::Spec->catdir($t_dir, 'testlib2');
27
28print "# OK, found the test corpora\n#  as $here1\n# and $here2\n";
29
30print $x->_state_as_string;
31#$x->verbose(12);
32
33use Pod::Simple;
34*pretty = \&Pod::Simple::BlackBox::pretty;
35
36print "# OK, starting run...\n# [[\n";
37my($name2where, $where2name) = $x->survey($here1, $here2);
38print "# ]]\n#OK, run done.\n";
39
40my $p = pretty( $where2name, $name2where )."\n";
41$p =~ s/, +/,\n/g;
42$p =~ s/^/#  /mg;
43print $p;
44
45require File::Spec->catfile($t_dir, 'ascii_order.pl');
46
47SKIP: {
48    skip '-- case may or may not be preserved', 2
49        if $^O eq 'VMS';
50
51    {
52        my $names = join "|", sort ascii_order values %$where2name;
53        is $names,
54            "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
55    }
56
57    {
58        my $names = join "|", sort ascii_order keys %$name2where;
59        is $names,
60            "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzoned|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
61    }
62}
63
64like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
65
66is grep( m/squaa\.pm/, keys %$where2name ), 1;
67
68###### Now with recurse(0)
69
70$x->recurse(0);
71
72print "# OK, starting run without recurse...\n# [[\n";
73($name2where, $where2name) = $x->survey($here1, $here2);
74print "# ]]\n#OK, run without recurse done.\n";
75
76$p = pretty( $where2name, $name2where )."\n";
77$p =~ s/, +/,\n/g;
78$p =~ s/^/#  /mg;
79print $p;
80
81SKIP: {
82    skip '-- case may or may not be preserved', 2
83        if $^O eq 'VMS';
84
85    {
86        my $names = join "|", sort ascii_order values %$where2name;
87        is $names,
88            "Blorm|Suzzle|squaa|zikzik";
89    }
90
91    {
92        my $names = join "|", sort ascii_order keys %$name2where;
93        is $names,
94            "Blorm|Suzzle|squaa|zikzik";
95    }
96}
97
98like( ($name2where->{'squaa'} || 'huh???'), qr/squaa\.pm$/);
99
100is grep( m/squaa\.pm/, keys %$where2name ), 1;
101