1#!perl
2#
3# test apparatus for Text::Template module
4# still incomplete.
5
6use strict;
7use warnings;
8use Test::More tests => 6;
9
10use_ok 'Text::Template' or exit 1;
11
12# (1-2) Missing source
13eval {
14    Text::Template->new();
15    pass;
16};
17
18like $@, qr/^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/;
19
20eval { Text::Template->new(TYPE => 'FILE'); };
21like $@, qr/^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/;
22
23# (3) Invalid type
24eval { Text::Template->new(TYPE => 'wlunch', SOURCE => 'fish food'); };
25like $@, qr/^\QIllegal value `WLUNCH' for TYPE parameter/;
26
27# (4-5) File does not exist
28my $o = Text::Template->new(
29    TYPE   => 'file',
30    SOURCE => 'this file does not exist');
31ok !defined $o;
32
33ok defined($Text::Template::ERROR)
34    && $Text::Template::ERROR =~ /^Couldn't open file/;
35