line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
408097
|
use 5.006; |
|
6
|
|
|
|
|
72
|
|
2
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
137
|
|
3
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
361
|
|
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
|
|
50
|
use base 'Exporter'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
613
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
41
|
use Carp qw(croak); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
359
|
|
15
|
6
|
|
|
6
|
|
2781
|
use EJS::Template; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
200
|
|
16
|
6
|
|
|
6
|
|
43
|
use Test::Builder; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
131
|
|
17
|
6
|
|
|
6
|
|
31
|
use Test::More; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
45
|
|
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
|
38326
|
my ($source, $expected, $variables, $config) = @_; |
29
|
50
|
|
|
|
|
139
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
30
|
|
|
|
|
|
|
|
31
|
50
|
100
|
|
|
|
113
|
my $ejs = EJS::Template->new(%{$config || {}}); |
|
50
|
|
|
|
|
513
|
|
32
|
50
|
|
|
|
|
169
|
my $prefix = ''; |
33
|
|
|
|
|
|
|
|
34
|
50
|
|
|
|
|
141
|
for my $name (qw(engine escape)) { |
35
|
100
|
100
|
|
|
|
521
|
if ($ejs->{$name}) { |
36
|
32
|
|
|
|
|
94
|
$prefix .= $ejs->{$name}.': '; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
50
|
|
100
|
|
|
212
|
$prefix ||= 'source: '; |
41
|
|
|
|
|
|
|
|
42
|
50
|
|
|
|
|
87
|
my $output; |
43
|
|
|
|
|
|
|
|
44
|
50
|
|
|
|
|
97
|
eval { |
45
|
50
|
50
|
|
|
|
212
|
$ejs->process(\$source, $variables, \$output) or croak $@; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
50
|
50
|
|
|
|
172
|
if ($@) { |
49
|
0
|
|
|
|
|
0
|
fail $prefix."[$source]: $@"; |
50
|
|
|
|
|
|
|
} else { |
51
|
50
|
|
|
|
|
396
|
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
|
10773
|
my ($source, $expected) = @_; |
61
|
20
|
|
|
|
|
41
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
62
|
|
|
|
|
|
|
|
63
|
20
|
|
|
|
|
27
|
my $prefix = 'source: '; |
64
|
20
|
|
|
|
|
30
|
my $output; |
65
|
|
|
|
|
|
|
|
66
|
20
|
|
|
|
|
26
|
eval { |
67
|
20
|
50
|
|
|
|
109
|
EJS::Template->parse(\$source, \$output) or croak $@; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
20
|
50
|
|
|
|
42
|
if ($@) { |
71
|
0
|
|
|
|
|
0
|
fail $prefix."[$source]: $@"; |
72
|
|
|
|
|
|
|
} else { |
73
|
20
|
|
|
|
|
76
|
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; |