This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
incorrectly failing test in lib/Pod/t/text.t
[perl5.git] / lib / Pod / t / utils.t
1
2 # Test hyperlinks et al from Pod::ParseUtils
3
4 BEGIN {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7         require Test; import Test;
8         plan(tests => 22);
9 }
10
11 use strict;
12 use Pod::ParseUtils;
13
14 # First test the hyperlinks
15
16 my @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
29 my @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
42 ok(@results,@links);
43
44 for 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
51 my $list = new Pod::List( -indent => 4,
52                           -start  => 52,
53                           -file   => "itemtest.t",
54                           -type   => "OL",
55                         );
56
57 ok($list);
58
59 ok($list->indent, 4);
60 ok($list->start, 52);
61 ok($list->type, "OL");
62
63
64 # Pod::Cache
65
66 # also needs work
67
68 my $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
78 my $item = $cache->find_page("Pod::ParseUtils");
79 ok($item);
80
81 # and a failure
82 ok($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
86 my @i = $cache->item;
87 ok($i[0], $item);
88
89 # Check the contents
90 ok($item->page, "Pod::ParseUtils");
91 ok($item->description, "A description");
92 ok($item->file, "file.t");