line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::Config; |
2
|
|
|
|
|
|
|
$CHI::t::Config::VERSION = '0.61'; |
3
|
1
|
|
|
1
|
|
1037
|
use CHI::Util qw(dump_one_line); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
81
|
|
4
|
1
|
|
|
1
|
|
530
|
use CHI::Test; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
742
|
use File::Temp qw(tempdir); |
|
1
|
|
|
|
|
18961
|
|
|
1
|
|
|
|
|
57
|
|
6
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
8
|
1
|
|
|
1
|
|
7
|
use base qw(CHI::Test::Class); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
454
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $root_dir = tempdir( 'CHI-t-Config-XXXX', TMPDIR => 1, CLEANUP => 1 ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %config = ( |
13
|
|
|
|
|
|
|
storage => { |
14
|
|
|
|
|
|
|
memory => { driver => 'Memory', global => 1 }, |
15
|
|
|
|
|
|
|
file => { driver => 'File', root_dir => $root_dir }, |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
namespace => { |
18
|
|
|
|
|
|
|
'Foo' => { storage => 'file' }, |
19
|
|
|
|
|
|
|
'Bar' => { storage => 'file', depth => 3 }, |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
defaults => { storage => 'memory' }, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
package My::CHI; |
26
|
|
|
|
|
|
|
$My::CHI::VERSION = '0.61'; |
27
|
1
|
|
|
1
|
|
7
|
use base qw(CHI); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
121
|
|
28
|
|
|
|
|
|
|
My::CHI->config( {%config} ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
package My::CHI::Subclass; |
33
|
|
|
|
|
|
|
$My::CHI::Subclass::VERSION = '0.61'; |
34
|
1
|
|
|
1
|
|
7
|
use base qw(My::CHI); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
469
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
package My::CHI::Memo; |
39
|
|
|
|
|
|
|
$My::CHI::Memo::VERSION = '0.61'; |
40
|
1
|
|
|
1
|
|
8
|
use base qw(CHI); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
410
|
|
41
|
|
|
|
|
|
|
My::CHI::Memo->config( { %config, memoize_cache_objects => 1 } ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _create { |
45
|
5
|
|
|
5
|
|
12
|
my ( $params, $checks ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
16
|
my $desc = dump_one_line($params); |
48
|
5
|
|
|
|
|
404
|
foreach my $class (qw(My::CHI My::CHI::Subclass)) { |
49
|
10
|
|
|
|
|
1721
|
my $cache = $class->new(%$params); |
50
|
10
|
|
|
|
|
42
|
while ( my ( $key, $value ) = each(%$checks) ) { |
51
|
50
|
|
|
|
|
14101
|
is( $cache->$key, $value, "$key == $value ($desc)" ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub test_config : Tests { |
57
|
1
|
|
|
1
|
0
|
1480
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
9
|
_create( |
60
|
|
|
|
|
|
|
{ namespace => 'Foo' }, |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
namespace => 'Foo', |
63
|
|
|
|
|
|
|
storage => 'file', |
64
|
|
|
|
|
|
|
short_driver_name => 'File', |
65
|
|
|
|
|
|
|
root_dir => $root_dir, |
66
|
|
|
|
|
|
|
depth => 2 |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
1
|
|
|
|
|
341
|
_create( |
70
|
|
|
|
|
|
|
{ namespace => 'Bar' }, |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
namespace => 'Bar', |
73
|
|
|
|
|
|
|
storage => 'file', |
74
|
|
|
|
|
|
|
short_driver_name => 'File', |
75
|
|
|
|
|
|
|
root_dir => $root_dir, |
76
|
|
|
|
|
|
|
depth => 3 |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
); |
79
|
1
|
|
|
|
|
337
|
_create( |
80
|
|
|
|
|
|
|
{ namespace => 'Foo', depth => 4 }, |
81
|
|
|
|
|
|
|
{ |
82
|
|
|
|
|
|
|
namespace => 'Foo', |
83
|
|
|
|
|
|
|
storage => 'file', |
84
|
|
|
|
|
|
|
short_driver_name => 'File', |
85
|
|
|
|
|
|
|
root_dir => $root_dir, |
86
|
|
|
|
|
|
|
depth => 4 |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
); |
89
|
1
|
|
|
|
|
345
|
_create( |
90
|
|
|
|
|
|
|
{ namespace => 'Bar', depth => 4 }, |
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
namespace => 'Bar', |
93
|
|
|
|
|
|
|
storage => 'file', |
94
|
|
|
|
|
|
|
short_driver_name => 'File', |
95
|
|
|
|
|
|
|
root_dir => $root_dir, |
96
|
|
|
|
|
|
|
depth => 4 |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
352
|
my %new_config = %config; |
101
|
1
|
|
|
|
|
4
|
$new_config{namespace}->{'Bar'}->{depth} = 5; |
102
|
1
|
|
|
|
|
7
|
My::CHI->config( {%new_config} ); |
103
|
1
|
|
|
|
|
7
|
_create( |
104
|
|
|
|
|
|
|
{ namespace => 'Bar' }, |
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
namespace => 'Bar', |
107
|
|
|
|
|
|
|
storage => 'file', |
108
|
|
|
|
|
|
|
short_driver_name => 'File', |
109
|
|
|
|
|
|
|
root_dir => $root_dir, |
110
|
|
|
|
|
|
|
depth => 5 |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
); |
113
|
1
|
|
|
1
|
|
9
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub test_memoize : Tests { |
116
|
1
|
|
|
1
|
0
|
1390
|
my $cache1 = My::CHI::Memo->new( namespace => 'Foo' ); |
117
|
1
|
|
|
|
|
4
|
my $cache2 = My::CHI::Memo->new( namespace => 'Foo' ); |
118
|
1
|
|
|
|
|
5
|
is( $cache1, $cache2, "same - namespace Foo" ); |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
356
|
my $cache3 = My::CHI::Memo->new( namespace => 'Bar', depth => 4 ); |
121
|
1
|
|
|
|
|
6
|
my $cache4 = My::CHI::Memo->new( namespace => 'Bar', depth => 4 ); |
122
|
1
|
|
|
|
|
7
|
isnt( $cache3, $cache4, "different - namespace Bar" ); |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
352
|
My::CHI::Memo->clear_memoized_cache_objects(); |
125
|
1
|
|
|
|
|
5
|
my $cache5 = My::CHI::Memo->new( namespace => 'Foo' ); |
126
|
1
|
|
|
|
|
4
|
my $cache6 = My::CHI::Memo->new( namespace => 'Foo' ); |
127
|
1
|
|
|
|
|
6
|
is( $cache5, $cache6, "same - namespace Foo" ); |
128
|
1
|
|
|
|
|
356
|
isnt( $cache1, $cache3, "different - post-clear" ); |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
339
|
my $cache7 = My::CHI->new( namespace => 'Foo' ); |
131
|
1
|
|
|
|
|
5
|
my $cache8 = My::CHI->new( namespace => 'Foo' ); |
132
|
1
|
|
|
|
|
5
|
isnt( $cache7, $cache8, "different - namespace Foo - no memoization" ); |
133
|
1
|
|
|
1
|
|
502
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |