openssl/external/perl/Text-Template-1.46/t/14-broken.t
Richard Levitte 8ff2af5483 Bundle the non core Perl module Text::Template
Because we're using Text::Template and we know it's a non core Perl
module, we choose to bundle it into our source, for convenience.

external/perl/Downloaded.txt document what modules we choose to bundle
this way and exactly where we downloaded it from.

With this changes comes the transfer module for with_fallback.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-01-22 23:12:22 +01:00

83 lines
2.3 KiB
Perl

#!perl
# test apparatus for Text::Template module
use Text::Template;
print "1..5\n";
$n=1;
die "This is the test program for Text::Template version 1.46.
You are using version $Text::Template::VERSION instead.
That does not make sense.\n
Aborting"
unless $Text::Template::VERSION == 1.46;
# (1) basic error delivery
{ my $r = Text::Template->new(TYPE => 'string',
SOURCE => '{1/0}',
)->fill_in();
if ($r eq q{Program fragment delivered error ``Illegal division by zero at template line 1.''}) {
print "ok $n\n";
} else {
print "not ok $n\n# $r\n";
}
$n++;
}
# (2) BROKEN sub called in ->new?
{ my $r = Text::Template->new(TYPE => 'string',
SOURCE => '{1/0}',
BROKEN => sub {'---'},
)->fill_in();
if ($r eq q{---}) {
print "ok $n\n";
} else {
print "not ok $n\n# $r\n";
}
$n++;
}
# (3) BROKEN sub called in ->fill_in?
{ my $r = Text::Template->new(TYPE => 'string',
SOURCE => '{1/0}',
)->fill_in(BROKEN => sub {'---'});
if ($r eq q{---}) {
print "ok $n\n";
} else {
print "not ok $n\n# $r\n";
}
$n++;
}
# (4) BROKEN sub passed correct args when called in ->new?
{ my $r = Text::Template->new(TYPE => 'string',
SOURCE => '{1/0}',
BROKEN => sub { my %a = @_;
qq{$a{lineno},$a{error},$a{text}}
},
)->fill_in();
if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
print "ok $n\n";
} else {
print "not ok $n\n# $r\n";
}
$n++;
}
# (5) BROKEN sub passed correct args when called in ->fill_in?
{ my $r = Text::Template->new(TYPE => 'string',
SOURCE => '{1/0}',
)->fill_in(BROKEN =>
sub { my %a = @_;
qq{$a{lineno},$a{error},$a{text}}
});
if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
print "ok $n\n";
} else {
print "not ok $n\n# $r\n";
}
$n++;
}