File: 06-file-cache-dir.t

package info (click to toggle)
libhtml-template-perl 2.97-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 740 kB
  • sloc: perl: 2,572; makefile: 8
file content (68 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;
use Test::More
  # qw(no_plan);
  tests => 4;

use_ok('HTML::Template');

my ($template);

eval {
    $template = HTML::Template->new(
        path     => ['templates/'],
        filename => 'simple.tmpl',
        #        file_cache_dir => './blib/temp_cache_dir',
        file_cache_dir => '',
        file_cache     => 1,
        #cache_debug => 1,
        #debug => 0,
    );
};
like($@, qr/^You must specify the file_cache_dir option/, "file_cache_dir option fails due to zero-length string");

eval {
    $template = HTML::Template->new(
        path           => ['templates/'],
        filename       => 'simple.tmpl',
        file_cache_dir => './blib/temp_cache_dir',
        file_cache     =>,                           # missing value; should generate error
                                                     #cache_debug => 1,
                                                     #debug => 0,
    );
};
like(
    $@,
    qr/HTML::Template->new\(\) called with odd number of option parameters - should be of the form option => value/,
    "odd number of arguments causes constructor to fail"
);

eval {
    $template = HTML::Template->new(
        path           => ['templates/'],
        filename       => 'simple.tmpl',
        file_cache_dir => './blib/temp_cache_dir',
        file_cache     => undef,                     # 'undef' counts as a missing value; should generate error
                                                     #cache_debug => 1,
                                                     #debug => 0,
    );
};
like(
    $@,
    qr/HTML::Template->new\(\) called with odd number of option parameters - should be of the form option => value/,
    "odd number of arguments causes constructor to fail"
);

=head1 NAME

t/06-file-cache-dir.t

=head1 OBJECTIVE

Test edge cases in use of C<file_cache> and C<file_cache_dir> options 
to constructor C<HTML::Template::new()>.  Example:  test case where 
C<file_cache> option is set to C<undef> but a C<file_cache_dir> value is
provided; examine error message.

=cut