line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::TT; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
61355
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Test::Builder; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
56
|
|
7
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
100
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
4116
|
use Template; |
|
2
|
|
|
|
|
72241
|
|
|
2
|
|
|
|
|
75
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
24
|
use vars qw( @ISA $VERSION @EXPORT ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1623
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Test::TT - Test::More-style wrapper around Template |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 0.01 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$VERSION = '0.01'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $TEST = Test::Builder->new; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Test::Template tests => 1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $table = build_display_table(); |
34
|
|
|
|
|
|
|
html_ok( $table, 'Built display table properly' ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This module provides a few convenience methods for testing exception |
39
|
|
|
|
|
|
|
based code. It is built with L and plays happily with |
40
|
|
|
|
|
|
|
L. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 EXPORT |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
C |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
@EXPORT = qw( tt_ok ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub import { |
51
|
3
|
|
|
3
|
|
115
|
my $self = shift; |
52
|
3
|
|
|
|
|
7
|
my $pack = caller; |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
17
|
$TEST->exported_to($pack); |
55
|
3
|
|
|
|
|
32
|
$TEST->plan(@_); |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
380
|
$self->export_to_level( 1, $self, @EXPORT ); |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
55
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 tt_ok( [$tt_options, ] $tt_data, $name, $vars, $output ) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Checks to see that C<$tt_data> is valid TT. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Checks to see if C<$tt_data> is valid TT. C<$tt_data> being blank is OK. |
67
|
|
|
|
|
|
|
C<$tt_data> being undef is not. C<$tt_data> will be passed directly to |
68
|
|
|
|
|
|
|
Template Toolkit, so you should pass a filename, a text reference or a |
69
|
|
|
|
|
|
|
file handle (GLOB). |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
If you pass a Template object, ( will use that for parsing. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
C<$vars> will be passed to the template object, and should be a hashref. Can be skipped. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
C<$output> will be passed to the template object, and specifies what to the do with the output. |
76
|
|
|
|
|
|
|
If not present tt_ok will silently eat all the output. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub tt_ok { |
81
|
5
|
|
|
5
|
1
|
230
|
my $template; |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
9
|
my $ok = 1; |
84
|
5
|
50
|
|
|
|
22
|
if ( ref( $_[0] ) eq 'Template' ) { |
85
|
0
|
|
|
|
|
0
|
$template = shift; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
5
|
|
|
|
|
45
|
$template = Template->new(); |
89
|
5
|
50
|
|
|
|
27713
|
if ( !$template ) { |
90
|
0
|
|
|
|
|
0
|
$ok = 0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
5
|
|
|
|
|
12
|
my $tt_data = shift; |
94
|
5
|
|
|
|
|
9
|
my $name = shift; |
95
|
5
|
|
|
|
|
6
|
my $vars = shift; |
96
|
5
|
|
|
|
|
7
|
my $output = shift; |
97
|
5
|
|
|
|
|
6
|
my $data; |
98
|
|
|
|
|
|
|
|
99
|
5
|
50
|
|
|
|
14
|
if ( !$ok ) { |
100
|
0
|
|
|
|
|
0
|
$TEST->ok( 0, $name ); |
101
|
0
|
|
|
|
|
0
|
my $msg = 'Errors:'; |
102
|
0
|
0
|
|
|
|
0
|
$msg .= " $name" if $name; |
103
|
0
|
|
|
|
|
0
|
$TEST->diag($msg); |
104
|
0
|
|
|
|
|
0
|
$TEST->diag( Template->error() ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
5
|
100
|
|
|
|
13
|
if ( !$output ) { |
108
|
4
|
|
|
|
|
6
|
$output = \$data; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
5
|
50
|
|
|
|
10
|
if ($ok) { |
112
|
5
|
|
|
|
|
13
|
$ok = defined $tt_data; |
113
|
5
|
100
|
|
|
|
11
|
if ( !$ok ) { |
114
|
1
|
|
|
|
|
8
|
$TEST->ok( 0, $name ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
5
|
100
|
|
|
|
424
|
if ($ok) { |
119
|
4
|
|
|
|
|
17
|
$ok = $template->process( $tt_data, $vars, $output ); |
120
|
4
|
|
|
|
|
39991
|
$TEST->ok( $ok, $name ); |
121
|
4
|
100
|
|
|
|
1456
|
if ( !$ok ) { |
122
|
2
|
|
|
|
|
4
|
my $msg = 'Errors:'; |
123
|
2
|
50
|
|
|
|
7
|
$msg .= " $name" if $name; |
124
|
2
|
|
|
|
|
7
|
$TEST->diag($msg); |
125
|
2
|
|
|
|
|
159
|
$TEST->diag( $template->error() ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
5
|
|
|
|
|
251
|
return $ok; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 BUGS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Please report any bugs to (patches welcome): |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Install-Debian |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ACKNOWLEGEMENTS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Thanks to chromatic and Michael G Schwern for the excellent Test::Builder. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Thanks to Andy Wardley for Template Toolkit. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Thanks to Adrian Howard for writing Test::Exception, from which most of |
151
|
|
|
|
|
|
|
this module is taken. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
BjErn-Olav Strand Ebo@startsiden.noE |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright 2009 by BjErn-Olav Strand . |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Please note that these modules are not products of or supported by the |
164
|
|
|
|
|
|
|
employers of the various contributors to the code. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
|