line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::Subcache; |
2
|
|
|
|
|
|
|
$CHI::t::Subcache::VERSION = '0.59'; |
3
|
1
|
|
|
1
|
|
635
|
use CHI::Test; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use CHI::Util qw(can_load); |
5
|
|
|
|
|
|
|
use base qw(CHI::Test::Class); |
6
|
|
|
|
|
|
|
use strict; |
7
|
|
|
|
|
|
|
use warnings; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub test_option_inheritance : Tests { |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
return 'Data::Serializer not installed' |
13
|
|
|
|
|
|
|
unless can_load('Data::Serializer'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my %params = ( |
16
|
|
|
|
|
|
|
expires_variance => 0.2, |
17
|
|
|
|
|
|
|
namespace => 'Blurg', |
18
|
|
|
|
|
|
|
on_get_error => 'warn', |
19
|
|
|
|
|
|
|
on_set_error => 'warn', |
20
|
|
|
|
|
|
|
serializer => 'Data::Dumper', |
21
|
|
|
|
|
|
|
depth => 4, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
my $cache = |
24
|
|
|
|
|
|
|
CHI->new( driver => 'File', %params, l1_cache => { driver => 'File' } ); |
25
|
|
|
|
|
|
|
foreach my $field (qw(expires_variance namespace on_get_error on_set_error)) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
is( $cache->$field, $cache->l1_cache->$field, "$field matches" ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
is( $cache->l1_cache->serializer->serializer, |
30
|
|
|
|
|
|
|
'Data::Dumper', 'l1 cache serializer' ); |
31
|
|
|
|
|
|
|
is( $cache->depth, 4, 'cache depth' ); |
32
|
|
|
|
|
|
|
is( $cache->l1_cache->depth, 2, 'l1 cache depth' ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub test_bad_subcache_option : Tests { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
throws_ok( |
38
|
|
|
|
|
|
|
sub { |
39
|
|
|
|
|
|
|
CHI->new( |
40
|
|
|
|
|
|
|
driver => 'Memory', |
41
|
|
|
|
|
|
|
global => 1, |
42
|
|
|
|
|
|
|
l1_cache => CHI->new( driver => 'Memory', global => 1 ) |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
qr/Validation failed for|isa check for .*? failed/, |
46
|
|
|
|
|
|
|
'cannot pass cache object as subcache' |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |