line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
79476
|
use 5.006; |
|
6
|
|
|
|
|
14
|
|
2
|
6
|
|
|
6
|
|
21
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
135
|
|
3
|
6
|
|
|
6
|
|
22
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
210
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
EJS::Template::Test - Testing utility for EJS::Template |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package EJS::Template::Test; |
12
|
6
|
|
|
6
|
|
20
|
use base 'Exporter'; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
459
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
23
|
use Carp qw(croak); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
293
|
|
15
|
6
|
|
|
6
|
|
2200
|
use EJS::Template; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
143
|
|
16
|
6
|
|
|
6
|
|
26
|
use Test::Builder; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
86
|
|
17
|
6
|
|
|
6
|
|
18
|
use Test::More; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
26
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT = qw(ejs_test ejs_test_parse); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 Methods |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 ejs_test |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub ejs_test { |
28
|
50
|
|
|
50
|
1
|
317004
|
my ($source, $expected, $variables, $config) = @_; |
29
|
50
|
|
|
|
|
98
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
30
|
|
|
|
|
|
|
|
31
|
50
|
100
|
|
|
|
67
|
my $ejs = EJS::Template->new(%{$config || {}}); |
|
50
|
|
|
|
|
420
|
|
32
|
50
|
|
|
|
|
78
|
my $prefix = ''; |
33
|
|
|
|
|
|
|
|
34
|
50
|
|
|
|
|
90
|
for my $name (qw(engine escape)) { |
35
|
100
|
100
|
|
|
|
232
|
if ($ejs->{$name}) { |
36
|
32
|
|
|
|
|
65
|
$prefix .= $ejs->{$name}.': '; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
50
|
|
100
|
|
|
128
|
$prefix ||= 'source: '; |
41
|
|
|
|
|
|
|
|
42
|
50
|
|
|
|
|
48
|
my $output; |
43
|
|
|
|
|
|
|
|
44
|
50
|
|
|
|
|
71
|
eval { |
45
|
50
|
50
|
|
|
|
146
|
$ejs->process(\$source, $variables, \$output) or croak $@; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
50
|
50
|
|
|
|
112
|
if ($@) { |
49
|
0
|
|
|
|
|
0
|
fail $prefix."[$source]: $@"; |
50
|
|
|
|
|
|
|
} else { |
51
|
50
|
|
|
|
|
263
|
is($output, $expected, $prefix."[$source]"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 ejs_test_parse |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub ejs_test_parse { |
60
|
20
|
|
|
20
|
1
|
73556
|
my ($source, $expected) = @_; |
61
|
20
|
|
|
|
|
28
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
62
|
|
|
|
|
|
|
|
63
|
20
|
|
|
|
|
17
|
my $prefix = 'source: '; |
64
|
20
|
|
|
|
|
15
|
my $output; |
65
|
|
|
|
|
|
|
|
66
|
20
|
|
|
|
|
21
|
eval { |
67
|
20
|
50
|
|
|
|
84
|
EJS::Template->parse(\$source, \$output) or croak $@; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
20
|
50
|
|
|
|
25
|
if ($@) { |
71
|
0
|
|
|
|
|
0
|
fail $prefix."[$source]: $@"; |
72
|
|
|
|
|
|
|
} else { |
73
|
20
|
|
|
|
|
55
|
is($output, $expected, $prefix."[$source]"); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |