This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add OP_ARGELEM, OP_ARGDEFELEM, OP_ARGCHECK ops
[perl5.git] / lib / Pod / t / utils.t
1 #!./perl -w
2 # Test hyperlinks et al from Pod::ParseUtils
3
4 use Test::More tests => 22;
5
6 use strict;
7 use Pod::ParseUtils;
8
9 my @links = qw{
10   name
11   name/ident
12   name/"sec"
13   "sec"
14   /"sec"
15   http://www.perl.org/
16   text|name
17   text|name/ident
18   text|name/"sec"
19   text|"sec"
20 };
21
22 my @results = (
23                "P<name>",
24                "Q<ident> in P<name>",
25                "Q<sec> in P<name>",
26                "Q<sec>",
27                "Q<sec>",
28                "Q<http://www.perl.org/>",
29                "Q<text>",
30                "Q<text>",
31                "Q<text>",
32                "Q<text>",
33               );
34
35 is(@results, @links, 'sanity check - array lengths equal?');
36
37 for my $i( 0..@links ) {
38   my $link = new Pod::Hyperlink( $links[$i] );
39   is($link->markup, $results[$i], "test hyperlink $i");
40 }
41
42 # Now test lists
43 # This test needs to be better
44 my $list = new Pod::List( -indent => 4,
45                           -start  => 52,
46                           -file   => "itemtest.t",
47                           -type   => "OL",
48                         );
49
50 ok($list);
51
52 is($list->indent, 4);
53 is($list->start, 52);
54 is($list->type, "OL");
55
56
57 # Pod::Cache
58
59 # also needs work
60
61 my $cache = new Pod::Cache;
62
63 # Store it in the cache
64 $cache->item(
65              -page => "Pod::ParseUtils",
66              -description => "A description",
67              -file => "file.t",
68  );
69
70 my $item = $cache->find_page("Pod::ParseUtils");
71 ok($item, 'found item of this name');
72
73 is($cache->find_page("Junk"), undef, 'expect to find nothing');
74
75 my @i = $cache->item;
76 is($i[0], $item, 'item we found is the same one as the first in the list');
77
78 # Check the contents
79 is($item->page, "Pod::ParseUtils");
80 is($item->description, "A description");
81 is($item->file, "file.t");