]> WPIA git - cassiopeia.git/blob - lib/openssl/external/perl/Text-Template-1.46/t/09-error.t
40f9fac6cbc81328730bfe8f391deae8390507d8
[cassiopeia.git] / lib / openssl / external / perl / Text-Template-1.46 / t / 09-error.t
1 #!perl
2 #
3 # test apparatus for Text::Template module
4 # still incomplete.
5
6 use Text::Template;
7
8 die "This is the test program for Text::Template version 1.46.
9 You are using version $Text::Template::VERSION instead.
10 That does not make sense.\n
11 Aborting"
12   unless $Text::Template::VERSION == 1.46;
13
14 print "1..5\n";
15 $n = 1;
16
17 # (1-2) Missing source
18 eval {
19   Text::Template->new();
20 };
21 unless ($@ =~ /^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/) {
22   print STDERR $@;
23   print "not ";
24 }
25 print "ok $n\n";
26 $n++;
27
28 eval {
29   Text::Template->new(TYPE => 'FILE');
30 };
31 if ($@ =~ /^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/) {
32   print "ok $n\n";
33 } else {
34   print STDERR $@;
35   print "not ok $n\n";
36 }
37 $n++;
38
39 # (3) Invalid type
40 eval {
41   Text::Template->new(TYPE => 'wlunch', SOURCE => 'fish food');
42 };
43 if ($@ =~ /^\QIllegal value `WLUNCH' for TYPE parameter/) {
44   print "ok $n\n";
45 } else {
46   print STDERR $@;
47   print "not ok $n\n";
48 }
49 $n++;
50
51 # (4-5) File does not exist
52 my $o = Text::Template->new(TYPE => 'file', 
53                             SOURCE => 'this file does not exist');
54 print $o ? "not ok $n\n" : "ok $n\n";
55 $n++;
56 print defined($Text::Template::ERROR) 
57       && $Text::Template::ERROR =~ /^Couldn't open file/
58   ? "ok $n\n" : "not ok $n\n";
59 $n++;
60
61
62 exit;
63