summaryrefslogtreecommitdiff
path: root/lib/Pod/t/utils.t
blob: 202ffd95105d80846b6032d9720fe76c23e89312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

# Test hyperlinks et al from Pod::ParseUtils

BEGIN {
        chdir 't' if -d 't';
        @INC = '../lib';
        require Test; import Test;
        plan(tests => 22);
}

use strict;
use Pod::ParseUtils;

# First test the hyperlinks

my @links = qw{
  name
  name/ident
  name/"sec"
  "sec"
  /"sec"
  http://www.perl.org/
  text|name
  text|name/ident
  text|name/"sec"
  text|"sec"
};

my @results = (
	       "the P<name> manpage",
	       "the Q<ident> entry in the P<name> manpage",
	       "the section on Q<sec> in the P<name> manpage",
	       "the section on Q<sec> elsewhere in this document",
	       "the section on Q<sec> elsewhere in this document",
	       "Q<http://www.perl.org/>",
	       "Q<text>",
	       "Q<text>",
	       "Q<text>",
	       "Q<text>",
	      );

ok(@results,@links);

for my $i( 0..@links ) {
  my $link = new Pod::Hyperlink( $links[$i] );
  ok($link->markup, $results[$i]);
}

# Now test lists
# This test needs to be better
my $list = new Pod::List( -indent => 4,
			  -start  => 52,
			  -file   => "itemtest.t",
			  -type   => "OL",
			);

ok($list);

ok($list->indent, 4);
ok($list->start, 52);
ok($list->type, "OL");


# Pod::Cache

# also needs work

my $cache = new Pod::Cache;

# Store it in the cache
$cache->item(
	     -page => "Pod::ParseUtils",
	     -description => "A description",
	     -file => "file.t",
 );

# Now look for an item of this name
my $item = $cache->find_page("Pod::ParseUtils");
ok($item);

# and a failure
ok($cache->find_page("Junk"), undef);

# Make sure that the item we found is the same one as the
# first in the list
my @i = $cache->item;
ok($i[0], $item);

# Check the contents
ok($item->page, "Pod::ParseUtils");
ok($item->description, "A description");
ok($item->file, "file.t");