Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (60 sloc) 1.522 kb
3ebfa07 Andy Wardley Initial revision
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/template.t
4 #
e39913f Andy Wardley *** empty log message ***
authored
5 # Test the Template.pm module. Does nothing of any great importance
6 # at the moment, but all of its options are tested in the various other
7 # test scripts.
3ebfa07 Andy Wardley Initial revision
authored
8 #
9 # Written by Andy Wardley <abw@kfs.org>
10 #
11 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
12 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
13 #
14 # This is free software; you can redistribute it and/or modify it
15 # under the same terms as Perl itself.
16 #
17 # $Id$
18 #
19 #========================================================================
20
21 use strict;
22 use lib qw( ./lib ../lib );
e39913f Andy Wardley *** empty log message ***
authored
23 use Template;
3ebfa07 Andy Wardley Initial revision
authored
24 use Template::Test;
25
82cbea8 Andy Wardley version 2.00
authored
26 my $out;
27 my $dir = -d 't' ? 't/test' : 'test';
28 my $tt = Template->new({
29 INCLUDE_PATH => "$dir/src:$dir/lib",
30 OUTPUT => \$out,
31 });
32
3ebfa07 Andy Wardley Initial revision
authored
33 ok( $tt );
82cbea8 Andy Wardley version 2.00
authored
34 ok( $tt->process('header') );
35 ok( $out );
36
37 $out = '';
38 ok( ! $tt->process('this_file_does_not_exist') );
39 my $error = $tt->error();
40 ok( $error->type() eq 'file' );
41 ok( $error->info() eq 'this_file_does_not_exist: not found' );
42
5274e24 Added ability to pass array reference as third argument to process.
Darren Chamberlain authored
43 my @output;
44 $tt->process('header', undef, \@output);
45 ok(length($output[-1]));
46
759c73b Andy Wardley * Applied patch from Leon to extend test coverage
authored
47 sub myout {
48 my $output = shift;
49 ok($output)
50 }
82cbea8 Andy Wardley version 2.00
authored
51
759c73b Andy Wardley * Applied patch from Leon to extend test coverage
authored
52 ok($tt->process('header', undef, \&myout));
53
e975211 Andy Wardley prep 2.4d
authored
54 $out = Myout->new();
759c73b Andy Wardley * Applied patch from Leon to extend test coverage
authored
55
56 ok($tt->process('header', undef, $out));
57
58 package Myout;
59 use Template::Test;
60
61 sub new {
62 my $proto = shift;
63 my $class = ref($proto) || $proto;
64 my $self = {};
65 bless($self, $class);
66 return $self;
67 }
68 sub print {
69 my $output = shift;
70 ok($output);
71 }
Something went wrong with that request. Please try again.