File: 054_Opt_cache.t

package info (click to toggle)
libpetal-perl 2.19-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 1,076 kB
  • ctags: 166
  • sloc: perl: 4,732; xml: 726; makefile: 43
file content (105 lines) | stat: -rw-r--r-- 2,459 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/perl
##############################################################################
# Tests the 'disk_cache' and 'memory_cache' options to Petal->new.
#

use Test::More tests => 12;

use warnings;
use lib 'lib';

use Petal;
use File::Spec;

my $data_dir = File::Spec->catdir('t', 'data');
my $file     = 'if.html';

# Confirm disk cache defaults to on

my $template = new Petal (file => $file, base_dir => $data_dir);

ok($template->disk_cache, "disk_cache defaults to on");


# Confirm option can disable it

$template = new Petal (file => $file, base_dir => $data_dir, disk_cache => 0);

ok(!$template->disk_cache, "disk_cache option turns it off");


# Confirm global can disable it

$Petal::DISK_CACHE = 0;
$template = new Petal (file => $file, base_dir => $data_dir);

ok(!$template->disk_cache, "\$Petal::DISK_CACHE turns it off");


# Confirm option can enable it

$template = new Petal (file => $file, base_dir => $data_dir, disk_cache => 1);

ok($template->disk_cache, "disk_cache option turns it on again");



# Confirm memory cache defaults to on

$template = new Petal (file => $file, base_dir => $data_dir);

ok($template->memory_cache, "memory_cache defaults to on");


# Confirm option can disable it

$template = new Petal (file => $file, base_dir => $data_dir, memory_cache => 0);

ok(!$template->memory_cache, "memory_cache option turns it off");


# Confirm global can disable it

$Petal::MEMORY_CACHE = 0;
$template = new Petal (file => $file, base_dir => $data_dir);

ok(!$template->memory_cache, "\$Petal::MEMORY_CACHE turns it off");


# Confirm option can enable it

$template = new Petal (file => $file, base_dir => $data_dir, memory_cache => 1);

ok($template->memory_cache, "memory_cache option turns it on again");



# Confirm cache_only defaults to off

$template = new Petal (file => $file, base_dir => $data_dir);

ok(!$template->cache_only, "cache_only defaults to off");


# Confirm option can enable it

$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 1);

ok($template->cache_only, "cache_only option turns it on");


# Confirm global can enable it

$Petal::CACHE_ONLY = 1;
$template = new Petal (file => $file, base_dir => $data_dir);

ok($template->cache_only, "\$Petal::CACHE_ONLY turns it on");


# Confirm option can disable it

$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 0);

ok(!$template->cache_only, "cache_only option turns it off again");