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