xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Pod/t/utils.t (revision 0:68f95e015346)
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	       "P<name>",
31	       "Q<ident> in P<name>",
32	       "Q<sec> in P<name>",
33	       "Q<sec>",
34	       "Q<sec>",
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");
93