File: 054_Opt_cache.t

package info (click to toggle)
libpetal-perl 2.18-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,036 kB
  • ctags: 165
  • sloc: perl: 4,613; xml: 703; makefile: 43
file content (75 lines) | stat: -rw-r--r-- 1,756 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
##############################################################################
# Tests the 'disk_cache' and 'memory_cache' options to Petal->new.
#

use Test::More tests => 8;

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");