Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2259a9579a
Fetching contributors…

Cannot retrieve contributors at this time

file 71 lines (60 sloc) 1.522 kb
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
#============================================================= -*-perl-*-
#
# t/template.t
#
# Test the Template.pm module. Does nothing of any great importance
# at the moment, but all of its options are tested in the various other
# test scripts.
#
# Written by Andy Wardley <abw@kfs.org>
#
# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id$
#
#========================================================================

use strict;
use lib qw( ./lib ../lib );
use Template;
use Template::Test;

my $out;
my $dir = -d 't' ? 't/test' : 'test';
my $tt = Template->new({
    INCLUDE_PATH => "$dir/src:$dir/lib",
    OUTPUT => \$out,
});

ok( $tt );
ok( $tt->process('header') );
ok( $out );

$out = '';
ok( ! $tt->process('this_file_does_not_exist') );
my $error = $tt->error();
ok( $error->type() eq 'file' );
ok( $error->info() eq 'this_file_does_not_exist: not found' );

my @output;
$tt->process('header', undef, \@output);
ok(length($output[-1]));

sub myout {
  my $output = shift;
  ok($output)
}

ok($tt->process('header', undef, \&myout));

$out = Myout->new();

ok($tt->process('header', undef, $out));

package Myout;
use Template::Test;

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self = {};
  bless($self, $class);
  return $self;
}
sub print {
  my $output = shift;
  ok($output);
}
Something went wrong with that request. Please try again.