This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add test for Pod::ParseUtils
[perl5.git] / lib / Pod / t / utils.t
CommitLineData
50b72f59
TJ
1
2# Test hyperlinks et al from Pod::ParseUtils
3
4BEGIN {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 require Test; import Test;
8 plan(tests => 22);
9}
10
11use strict;
12use Pod::ParseUtils;
13
14# First test the hyperlinks
15
16my @links = qw{
17 name
18 name/ident
19 name/"sec"
20 "sec"
21 /"sec"
22 http://www.perl.org/
23 text|name
24 text|name/ident
25 text|name/"sec"
26 text|"sec"
27};
28
29my @results = (
30 "the P<name> manpage",
31 "the Q<ident> entry in the P<name> manpage",
32 "the section on Q<sec> in the P<name> manpage",
33 "the section on Q<sec> elsewhere in this document",
34 "the section on Q<sec> elsewhere in this document",
35 "Q<http://www.perl.org/>",
36 "Q<text>",
37 "Q<text>",
38 "Q<text>",
39 "Q<text>",
40 );
41
42ok(@results,@links);
43
44for my $i( 0..@links ) {
45 my $link = new Pod::Hyperlink( $links[$i] );
46 ok($link->markup, $results[$i]);
47}
48
49# Now test lists
50# This test needs to be better
51my $list = new Pod::List( -indent => 4,
52 -start => 52,
53 -file => "itemtest.t",
54 -type => "OL",
55 );
56
57ok($list);
58
59ok($list->indent, 4);
60ok($list->start, 52);
61ok($list->type, "OL");
62
63
64# Pod::Cache
65
66# also needs work
67
68my $cache = new Pod::Cache;
69
70# Store it in the cache
71$cache->item(
72 -page => "Pod::ParseUtils",
73 -description => "A description",
74 -file => "file.t",
75 );
76
77# Now look for an item of this name
78my $item = $cache->find_page("Pod::ParseUtils");
79ok($item);
80
81# and a failure
82ok($cache->find_page("Junk"), undef);
83
84# Make sure that the item we found is the same one as the
85# first in the list
86my @i = $cache->item;
87ok($i[0], $item);
88
89# Check the contents
90ok($item->page, "Pod::ParseUtils");
91ok($item->description, "A description");
92ok($item->file, "file.t");