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