Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (67 sloc) 1.872 kb
7dc261c @abw *** empty log message ***
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/compile4.t
4 #
5 # Test the facility for the Template::Provider to maintain a persistance
6 # cache of compiled templates by writing generated Perl code to files.
7 # This is similar to compile1.t but defines COMPILE_DIR as well as
8 # COMPILE_EXT.
9 #
10 # Written by Andy Wardley <abw@kfs.org>
11 #
12 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
13 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
14 #
15 # This is free software; you can redistribute it and/or modify it
16 # under the same terms as Perl itself.
17 #
18 # $Id$
19 #
20 #========================================================================
21
22 use strict;
23 use lib qw( ./lib ../lib );
24 use Template::Test;
25 use Cwd qw( abs_path );
26 use File::Path;
27 $^W = 1;
28
29 # declare extra tests to follow test_expect();
30 #$Template::Test::EXTRA = 2;
31
32 # script may be being run in distribution root or 't' directory
33 my $dir = abs_path( -d 't' ? 't/test' : 'test' );
34 my $cdir = abs_path("$dir/tmp") . "/cache";
35 my $ttcfg = {
36 POST_CHOMP => 1,
37 INCLUDE_PATH => "$dir/src",
38 COMPILE_DIR => $cdir,
39 COMPILE_EXT => '.ttc',
40 };
41
42 # delete any existing cache files
43 rmtree($cdir) if -d $cdir;
44 mkpath($cdir);
45
46 test_expect(\*DATA, $ttcfg);
47
48
49 __DATA__
50 -- test --
51 [% TRY %]
52 [% INCLUDE foo %]
53 [% CATCH file %]
54 Error: [% error.type %] - [% error.info %]
55 [% END %]
56 -- expect --
57 This is the foo file, a is
58
59 -- test --
60 [% META author => 'abw' version => 3.14 %]
61 [% INCLUDE complex %]
62 -- expect --
63 This is the header, title: Yet Another Template Test
64 This is a more complex file which includes some BLOCK definitions
65 This is the footer, author: abw, version: 3.14
5068caf @abw *** empty log message ***
authored
66 - 3 - 2 - 1
0b63aae @abw *** empty log message ***
authored
67
68 -- test --
69 [% TRY %]
70 [% INCLUDE bar/baz word = 'wibble' %]
71 [% CATCH file %]
72 Error: [% error.type %] - [% error.info %]
73 [% END %]
74 -- expect --
75 This is file baz
76 The word is 'wibble'
77
Something went wrong with that request. Please try again.