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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
# testing link_tree
use strict;
use Test::More tests => 6;
use HTML::LinkList qw(link_tree);
my @links = (
'/foo/bar/baz.html',
'/fooish.html',
'/bringle/',
['/tray/nav.html',
'/tray/tea_tray.html'],
);
my %labels = (
'/tray/nav.html' => 'Navigation',
'/foo/bar/baz.html' => 'Bazzy',
);
my $link_html = '';
# default, no current
$link_html = link_tree(labels=>\%labels,
link_tree=>\@links);
ok($link_html, "(1) default; links HTML");
my $ok_str = '';
$ok_str = '<ul><li><a href="/foo/bar/baz.html">Bazzy</a></li>
<li><a href="/fooish.html">Fooish</a></li>
<li><a href="/bringle/">Bringle</a>
<ul><li><a href="/tray/nav.html">Navigation</a></li>
<li><a href="/tray/tea_tray.html">Tea Tray</a></li>
</ul></li>
</ul>';
is($link_html, $ok_str, "(1) default; values match");
# not-welformed list
@links = (
['#Askew'],
'#Big',
['#Lower'],
);
%labels = (
'#Askew' => 'Askew Header',
'#Big' => 'Big Header',
'#Lower' => 'Lower Section',
);
$link_html = link_tree(labels=>\%labels,
link_tree=>\@links);
ok($link_html, "(2) not-wellformed; links HTML");
$ok_str = '<ul><li>
<ul><li><a href="#Askew">Askew Header</a></li>
</ul></li>
<li><a href="#Big">Big Header</a>
<ul><li><a href="#Lower">Lower Section</a></li>
</ul></li>
</ul>';
is($link_html, $ok_str, "(2) not-wellformed; values match");
#
# (3) more complicated (example from HTML::GenToc tests)
#
@links =
(
[
'tfiles/test5.php#Title-Archaeology701',
'tfiles/test5.php#Title-Platinum',
'tfiles/test5.php#Title-RoutineTrafficStop'
],
'tfiles/test5.php#Series-FauxPawsProductions',
[
'tfiles/test5.php#Title-WindShiftFPP-506'
]
);
%labels =
(
'tfiles/test5.php#Title-Archaeology701' => 'Archaeology 701 (Sentinel)',
'tfiles/test5.php#Title-Platinum' => 'Platinum (Sentinel)',
'tfiles/test5.php#Title-RoutineTrafficStop' => 'Routine Traffic Stop (Sentinel/ER)',
'tfiles/test5.php#Title-WindShiftFPP-506' => '(520) Wind Shift (FPP-506) (Sentinel)',
'tfiles/test5.php#Series-FauxPawsProductions' => 'Faux Paws Productions'
);
my %formats =
(
'0' => {
'tree_head' => '<ol>',
'tree_foot' => "\n</ol>",
},
'1' => {
'tree_head' => '<ul>',
'tree_foot' => "\n</ul>"
},
);
$link_html = link_tree(labels=>\%labels,
link_tree=>\@links,
formats=>\%formats);
ok($link_html, "(3) not-wellformed; links HTML");
$ok_str = '<ol><li>
<ul><li><a href="tfiles/test5.php#Title-Archaeology701">Archaeology 701 (Sentinel)</a></li>
<li><a href="tfiles/test5.php#Title-Platinum">Platinum (Sentinel)</a></li>
<li><a href="tfiles/test5.php#Title-RoutineTrafficStop">Routine Traffic Stop (Sentinel/ER)</a></li>
</ul></li>
<li><a href="tfiles/test5.php#Series-FauxPawsProductions">Faux Paws Productions</a>
<ul><li><a href="tfiles/test5.php#Title-WindShiftFPP-506">(520) Wind Shift (FPP-506) (Sentinel)</a></li>
</ul></li>
</ol>';
is($link_html, $ok_str, "(3) not-wellformed; values match");
|