| 1 | package CHI::t::Subcache; | ||||||||||
| 2 | 1 | $CHI::t::Subcache::VERSION = '0.59'; | |||||||||
| 3 | 1 | ▶ | use CHI::Test; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use CHI::Util qw(can_load); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use base qw(CHI::Test::Class); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | sub test_option_inheritance : Tests { | ||||||||||
| 10 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
test_option_inheritance: called CC=3 SCAR=18.7
Pod
undocumented
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | return 'Data::Serializer not installed' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | unless can_load('Data::Serializer'); | ||||||||||
| 14 | |||||||||||
| 15 | 0 | 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 | 0 | my $cache = | |||||||||
| 24 | CHI->new( driver => 'File', %params, l1_cache => { driver => 'File' } ); | ||||||||||
| 25 | 0 | foreach my $field (qw(expires_variance namespace on_get_error on_set_error)) | |||||||||
| 26 | { | ||||||||||
| 27 | 0 | is( $cache->$field, $cache->l1_cache->$field, "$field matches" ); | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | is( $cache->l1_cache->serializer->serializer, | |||||||||
| 30 | 'Data::Dumper', 'l1 cache serializer' ); | ||||||||||
| 31 | 0 | is( $cache->depth, 4, 'cache depth' ); | |||||||||
| 32 | 0 | is( $cache->l1_cache->depth, 2, 'l1 cache depth' ); | |||||||||
| 33 | 1 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | |||||||||||
| 35 | sub test_bad_subcache_option : Tests { | ||||||||||
| 36 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
test_bad_subcache_option: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 37 | throws_ok( | ||||||||||
| 38 | sub { | ||||||||||
| 39 | 1 | ▶ | CHI->new( | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 40 | driver => 'Memory', | ||||||||||
| 41 | global => 1, | ||||||||||
| 42 | l1_cache => CHI->new( driver => 'Memory', global => 1 ) | ||||||||||
| 43 | ); | ||||||||||
| 44 | }, | ||||||||||
| 45 | 1 | qr/Validation failed for|isa check for .*? failed/, | |||||||||
| 46 | 'cannot pass cache object as subcache' | ||||||||||
| 47 | ); | ||||||||||
| 48 | 1 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||