File: pod.t

package info (click to toggle)
libtemplate-perl 2.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 5,496 kB
  • ctags: 667
  • sloc: perl: 15,349; makefile: 62; xml: 7; sh: 5
file content (152 lines) | stat: -rw-r--r-- 2,782 bytes parent folder | download
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#============================================================= -*-perl-*-
#
# t/pod.t
#
# Tests the 'Pod' plugin.
#
# Written by Andy Wardley <abw@kfs.org>
#
# Copyright (C) 2001 Andy Wardley. All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id: pod.t,v 2.6 2002/08/12 11:07:17 abw Exp $
#
#========================================================================

use strict;
use lib qw( ./lib ../lib );
use Template::Test;
use Carp qw( confess );
$^W = 1;

$Template::Test::DEBUG = 0;
$Template::Test::PRESERVE = 1;
#$Template::View::DEBUG = 1;

eval "use Pod::POM";
if ($@) {
    skip_all('Pod::POM not installed');
}

my $config = {
    INCLUDE_PATH => 'templates:../templates',
#    RELATIVE     => 1,
#    POST_CHOMP   => 1,
};

my $vars = {
    podloc => -d 't' ? 't/test/pod' : 'test/pod',
};

test_expect(\*DATA, $config, $vars);

__DATA__
-- test --
[%  USE pod;
    pom = pod.parse("$podloc/no_such_file.pod");
    pom ? 'not ok' : 'ok'; ' - file does not exist';
%]
-- expect --
ok - file does not exist

-- test --
[%  USE pod;
    pom = pod.parse("$podloc/test1.pod");
    pom ? 'ok' : 'not ok'; ' - file parsed';
    global.pom = pom;
    global.warnings = pod.warnings;
%]
-- expect --
ok - file parsed

-- test --
[%  global.warnings.join("\n") %]
-- expect --
-- process --
spurious '>' at [% podloc %]/test1.pod line 17
spurious '>' at [% podloc %]/test1.pod line 21

-- test --
[% FOREACH h1 = global.pom.head1 -%]
* [% h1.title %]
[% END %]
-- expect --
* NAME
* SYNOPSIS
* DESCRIPTION
* THE END

-- test --
[% FOREACH h2 = global.pom.head1.2.head2 -%]
+ [% h2.title %]
[% END %]
-- expect --
+ First Subsection
+ Second Subsection

-- test --
[% PROCESS $item.type FOREACH item=global.pom.head1.2.content %]

[% BLOCK head2 -%]
<h2>[% item.title | trim %]</h2>
[% END %]

[% BLOCK text -%]
<p>[% item | trim %]</p>
[% END %]

[% BLOCK verbatim -%]
<pre>[% item | trim %]</pre>
[% END %]
-- expect --
<p>This is the description for My::Module.</p>
<pre>This is verbatim</pre>
<h2>First Subsection</h2>
<h2>Second Subsection</h2>

-- test --
[%  VIEW v prefix='pod/html/';
	BLOCK list; 
	    view.print(i) FOREACH i = item; 
	END;
    END;
    v.print(global.pom);
%]
-- expect --
<!-- Pod to HTML conversion by the Template Toolkit version 2 -->
<h1>NAME</h1>

<p>
My::Module
</p>

<h1>SYNOPSIS</h1>

<pre>    use My::Module;</pre>

<h1>DESCRIPTION</h1>

<p>
This is the description for My::Module.
</p>
<pre>    This is verbatim</pre>
<h2>First Subsection</h2>

<p>
This is the first subsection.  foo-&gt;bar();
</p>

<h2>Second Subsection</h2>

<p>
This is the second subsection.  bar-&gt;baz();
</p>


<h1>THE END</h1>

<p>
This is the end.  Beautiful friend, the end.
</p>