blib/lib/Mason/t/Cache.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 24 CC 1 SCAR 6.9
CC
1
Cov
0%
test_cache_defaults
2.0
test_cache_method
2.0
test_cache_filter
2.0
CRAP 2.0
1 package Mason::t::Cache;
2 $Mason::t::Cache::VERSION = '2.24';
3 use Test::Class::Most parent => 'Mason::Test::Class';
4  
5 __PACKAGE__->default_plugins( [ '@Default', 'Cache' ] );
6  
7 sub test_cache_defaults : Tests {
8 my $self = shift;
9 $self->run_test_in_comp(
10 path => '/cache/defaults.mc',
11 test => sub {
12 my $comp = shift;
13 is( $comp->cache->label, 'File', 'cache->label' );
14 is( $comp->cache->namespace, $comp->cmeta->path, 'cache->namespace' );
15 }
16 );
17 }
18  
19 sub test_cache_method : Tests {
20 my $self = shift;
21 $self->test_comp(
22 path => '/cache.mc',
23 src => '
24 <%class>
25 has "count" => ( default => 0 );
26  
27 </%class>
28  
29 <%method getset ($key)>
30 <%perl>$.count($.count+1);</%perl>
31 <% $.cache->compute($key, sub { $key . $.count }) %>
32 </%method>
33  
34 namespace: <% $.cache->namespace %>
35 <% $.getset("foo") %>
36 <% $.getset("bar") %>
37 <% $.getset("bar") %>
38 <% $.getset("foo") %>
39 ',
40 expect => '
41 namespace: /cache.mc
42 foo1
43  
44 bar2
45  
46 bar2
47  
48 foo1
49 ',
50 );
51 }
52  
53 sub test_cache_filter : Tests {
54 my $self = shift;
55  
56 $self->test_comp(
57 src => '
58 % my $i = 1;
59 % foreach my $key (qw(foo bar)) {
60 % $.Repeat(3), $.Cache($key) {{
61 i = <% $i++ %>
62 % }}
63 % }
64 ',
65 expect => '
66 i = 1
67 i = 1
68 i = 1
69 i = 2
70 i = 2
71 i = 2
72 ',
73 );
74  
75 $self->test_comp(
76 src => '
77 % my $i = 1;
78 % foreach my $key (qw(foo foo)) {
79 % $.Cache($key), $.Repeat(3) {{
80 i = <% $i++ %>
81 % }}
82 % }
83 ',
84 expect => '
85 i = 1
86 i = 2
87 i = 3
88 i = 1
89 i = 2
90 i = 3
91 '
92 );
93 }