Import OpenSSL 1.1.0f
This commit is contained in:
11
external/perl/Text-Template-1.46/t/00-version.t
vendored
Normal file
11
external/perl/Text-Template-1.46/t/00-version.t
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#!perl
|
||||
|
||||
use Text::Template;
|
||||
print "1..1\n";
|
||||
|
||||
if ($Text::Template::VERSION == 1.46) {
|
||||
print "ok 1\n";
|
||||
} else {
|
||||
print "not ok 1\n";
|
||||
}
|
||||
|
||||
266
external/perl/Text-Template-1.46/t/01-basic.t
vendored
Normal file
266
external/perl/Text-Template-1.46/t/01-basic.t
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
#!perl
|
||||
#
|
||||
# Tests of basic, essential functionality
|
||||
#
|
||||
|
||||
use Text::Template;
|
||||
$X::v = $Y::v = 0; # Suppress `var used only once'
|
||||
|
||||
print "1..31\n";
|
||||
|
||||
$n=1;
|
||||
|
||||
$template_1 = <<EOM;
|
||||
We will put value of \$v (which is "abc") here -> {\$v}
|
||||
We will evaluate 1+1 here -> {1 + 1}
|
||||
EOM
|
||||
|
||||
# (1) Construct temporary template file for testing
|
||||
# file operations
|
||||
$TEMPFILE = "tt$$";
|
||||
open(TMP, "> $TEMPFILE") or print "not ok $n\n" && &abort("Couldn\'t write tempfile $TEMPFILE: $!");
|
||||
print TMP $template_1;
|
||||
close TMP;
|
||||
print "ok $n\n"; $n++;
|
||||
|
||||
# (2) Build template from file
|
||||
$template = new Text::Template ('type' => 'FILE', 'source' => $TEMPFILE);
|
||||
if (defined($template)) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n $Text::Template::ERROR\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (3) Fill in template from file
|
||||
$X::v = "abc";
|
||||
$resultX = <<EOM;
|
||||
We will put value of \$v (which is "abc") here -> abc
|
||||
We will evaluate 1+1 here -> 2
|
||||
EOM
|
||||
$Y::v = "ABC";
|
||||
$resultY = <<EOM;
|
||||
We will put value of \$v (which is "abc") here -> ABC
|
||||
We will evaluate 1+1 here -> 2
|
||||
EOM
|
||||
|
||||
$text = $template->fill_in('package' => X);
|
||||
if ($text eq $resultX) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (4) Fill in same template again
|
||||
$text = $template->fill_in('package' => Y);
|
||||
if ($text eq $resultY) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
|
||||
|
||||
# (5) Simple test of `fill_this_in'
|
||||
$text = Text::Template->fill_this_in( $template_1, 'package' => X);
|
||||
if ($text eq $resultX) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (6) test creation of template from filehandle
|
||||
if (open (TMPL, "< $TEMPFILE")) {
|
||||
$template = new Text::Template ('type' => 'FILEHANDLE',
|
||||
'source' => *TMPL);
|
||||
if (defined($template)) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n $Text::Template::ERROR\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (7) test filling in of template from filehandle
|
||||
$text = $template->fill_in('package' => X);
|
||||
if ($text eq $resultX) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (8) test second fill_in on same template object
|
||||
$text = $template->fill_in('package' => Y);
|
||||
if ($text eq $resultY) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
close TMPL;
|
||||
} else {
|
||||
print "not ok $n\n"; $n++;
|
||||
print "not ok $n\n"; $n++;
|
||||
print "not ok $n\n"; $n++;
|
||||
}
|
||||
|
||||
|
||||
# (9) test creation of template from array
|
||||
$template = new Text::Template
|
||||
('type' => 'ARRAY',
|
||||
'source' => [
|
||||
'We will put value of $v (which is "abc") here -> {$v}',
|
||||
"\n",
|
||||
'We will evaluate 1+1 here -> {1+1}',
|
||||
"\n",
|
||||
]);
|
||||
if (defined($template)) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n $Text::Template::ERROR\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (10) test filling in of template from array
|
||||
$text = $template->fill_in('package' => X);
|
||||
if ($text eq $resultX) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (11) test second fill_in on same array template object
|
||||
$text = $template->fill_in('package' => Y);
|
||||
if ($text eq $resultY) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
print STDERR "$resultX\n---\n$text";
|
||||
unless (!defined($text)) { print STDERR "ERROR: $Text::Template::ERROR\n"};
|
||||
}
|
||||
$n++;
|
||||
|
||||
|
||||
|
||||
# (12) Make sure \ is working properly
|
||||
# Test added for version 1.11
|
||||
my $tmpl = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => 'B{"\\}"}C{"\\{"}D',
|
||||
);
|
||||
# This should fail if the \ are not interpreted properly.
|
||||
my $text = $tmpl->fill_in();
|
||||
print +($text eq "B}C{D" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (13) Make sure \ is working properly
|
||||
# Test added for version 1.11
|
||||
$tmpl = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => qq{A{"\t"}B},
|
||||
);
|
||||
# Symptom of old problem: ALL \ were special in templates, so
|
||||
# The lexer would return (A, PROGTEXT("t"), B), and the
|
||||
# result text would be AtB instead of A(tab)B.
|
||||
$text = $tmpl->fill_in();
|
||||
|
||||
print +($text eq "A\tB" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (14-27) Make sure \ is working properly
|
||||
# Test added for version 1.11
|
||||
# This is a sort of general test.
|
||||
my @tests = ('{""}' => '', # (14)
|
||||
'{"}"}' => undef, # (15)
|
||||
'{"\\}"}' => '}', # One backslash
|
||||
'{"\\\\}"}' => undef, # Two backslashes
|
||||
'{"\\\\\\}"}' => '}', # Three backslashes
|
||||
'{"\\\\\\\\}"}' => undef, # Four backslashes
|
||||
'{"\\\\\\\\\\}"}' => '\}', # Five backslashes (20)
|
||||
'{"x20"}' => 'x20',
|
||||
'{"\\x20"}' => ' ', # One backslash
|
||||
'{"\\\\x20"}' => '\\x20', # Two backslashes
|
||||
'{"\\\\\\x20"}' => '\\ ', # Three backslashes
|
||||
'{"\\\\\\\\x20"}' => '\\\\x20', # Four backslashes (25)
|
||||
'{"\\\\\\\\\\x20"}' => '\\\\ ', # Five backslashes
|
||||
'{"\\x20\\}"}' => ' }', # (27)
|
||||
);
|
||||
|
||||
my $i;
|
||||
for ($i=0; $i<@tests; $i+=2) {
|
||||
my $tmpl = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => $tests[$i],
|
||||
);
|
||||
my $text = $tmpl->fill_in;
|
||||
my $result = $tests[$i+1];
|
||||
my $ok = (! defined $text && ! defined $result
|
||||
|| $text eq $result);
|
||||
unless ($ok) {
|
||||
print STDERR "($n) expected .$result., got .$text.\n";
|
||||
}
|
||||
print +($ok ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
}
|
||||
|
||||
|
||||
# (28-30) I discovered that you can't pass a glob ref as your filehandle.
|
||||
# MJD 20010827
|
||||
# (28) test creation of template from filehandle
|
||||
if (open (TMPL, "< $TEMPFILE")) {
|
||||
$template = new Text::Template ('type' => 'FILEHANDLE',
|
||||
'source' => \*TMPL);
|
||||
if (defined($template)) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n $Text::Template::ERROR\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (29) test filling in of template from filehandle
|
||||
$text = $template->fill_in('package' => X);
|
||||
if ($text eq $resultX) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (30) test second fill_in on same template object
|
||||
$text = $template->fill_in('package' => Y);
|
||||
if ($text eq $resultY) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
close TMPL;
|
||||
} else {
|
||||
print "not ok $n\n"; $n++;
|
||||
print "not ok $n\n"; $n++;
|
||||
print "not ok $n\n"; $n++;
|
||||
}
|
||||
|
||||
# (31) Test _scrubpkg for leakiness
|
||||
$Text::Template::GEN0::test = 1;
|
||||
Text::Template::_scrubpkg('Text::Template::GEN0');
|
||||
if ($Text::Template::GEN0::test) {
|
||||
print "not ok $n\n";
|
||||
} else {
|
||||
print "ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
|
||||
END {unlink $TEMPFILE;}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub abort {
|
||||
unlink $TEMPFILE;
|
||||
die $_[0];
|
||||
}
|
||||
111
external/perl/Text-Template-1.46/t/02-hash.t
vendored
Normal file
111
external/perl/Text-Template-1.46/t/02-hash.t
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
print "1..12\n";
|
||||
|
||||
$n=1;
|
||||
|
||||
$template = 'We will put value of $v (which is "good") here -> {$v}';
|
||||
|
||||
$v = 'oops (main)';
|
||||
$Q::v = 'oops (Q)';
|
||||
|
||||
$vars = { 'v' => \'good' };
|
||||
|
||||
# (1) Build template from string
|
||||
$template = new Text::Template ('type' => 'STRING', 'source' => $template);
|
||||
print +($template ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (2) Fill in template in anonymous package
|
||||
$result2 = 'We will put value of $v (which is "good") here -> good';
|
||||
$text = $template->fill_in(HASH => $vars);
|
||||
print +($text eq $result2 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (3) Did we clobber the main variable?
|
||||
print +($v eq 'oops (main)' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (4) Fill in same template again
|
||||
$result4 = 'We will put value of $v (which is "good") here -> good';
|
||||
$text = $template->fill_in(HASH => $vars);
|
||||
print +($text eq $result4 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (5) Now with a package
|
||||
$result5 = 'We will put value of $v (which is "good") here -> good';
|
||||
$text = $template->fill_in(HASH => $vars, PACKAGE => 'Q');
|
||||
print +($text eq $result5 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (6) We expect to have clobbered the Q variable.
|
||||
print +($Q::v eq 'good' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (7) Now let's try it without a package
|
||||
$result7 = 'We will put value of $v (which is "good") here -> good';
|
||||
$text = $template->fill_in(HASH => $vars);
|
||||
print +($text eq $result7 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (8-11) Now what does it do when we pass a hash with undefined values?
|
||||
# Roy says it does something bad. (Added for 1.20.)
|
||||
my $WARNINGS = 0;
|
||||
{
|
||||
local $SIG{__WARN__} = sub {$WARNINGS++};
|
||||
local $^W = 1; # Make sure this is on for this test
|
||||
$template8 = 'We will put value of $v (which is "good") here -> {defined $v ? "bad" : "good"}';
|
||||
$result8 = 'We will put value of $v (which is "good") here -> good';
|
||||
my $template =
|
||||
new Text::Template ('type' => 'STRING', 'source' => $template8);
|
||||
my $text = $template->fill_in(HASH => {'v' => undef});
|
||||
# (8) Did we generate a warning?
|
||||
print +($WARNINGS == 0 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (9) Was the output correct?
|
||||
print +($text eq $result8 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (10-11) Let's try that again, with a twist this time
|
||||
$WARNINGS = 0;
|
||||
$text = $template->fill_in(HASH => [{'v' => 17}, {'v' => undef}]);
|
||||
# (10) Did we generate a warning?
|
||||
print +($WARNINGS == 0 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (11) Was the output correct?
|
||||
if ($] < 5.005) {
|
||||
print "ok $n # skipped -- not supported before 5.005\n";
|
||||
} else {
|
||||
print +($text eq $result8 ? '' : 'not '), "ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
|
||||
|
||||
# (12) Now we'll test the multiple-hash option (Added for 1.20.)
|
||||
$text = Text::Template::fill_in_string(q{$v: {$v}. @v: [{"@v"}].},
|
||||
HASH => [{'v' => 17},
|
||||
{'v' => ['a', 'b', 'c']},
|
||||
{'v' => \23},
|
||||
]);
|
||||
$result = q{$v: 23. @v: [a b c].};
|
||||
print +($text eq $result ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
56
external/perl/Text-Template-1.46/t/03-out.t
vendored
Normal file
56
external/perl/Text-Template-1.46/t/03-out.t
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
#
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
print "1..1\n";
|
||||
|
||||
$n=1;
|
||||
|
||||
$template = q{
|
||||
This line should have a 3: {1+2}
|
||||
|
||||
This line should have several numbers:
|
||||
{ $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
|
||||
};
|
||||
|
||||
$templateOUT = q{
|
||||
This line should have a 3: { $OUT = 1+2 }
|
||||
|
||||
This line should have several numbers:
|
||||
{ foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
|
||||
};
|
||||
|
||||
# Build templates from string
|
||||
$template = new Text::Template ('type' => 'STRING', 'source' => $template)
|
||||
or die;
|
||||
$templateOUT = new Text::Template ('type' => 'STRING', 'source' => $templateOUT)
|
||||
or die;
|
||||
|
||||
# Fill in templates
|
||||
$text = $template->fill_in()
|
||||
or die;
|
||||
$textOUT = $templateOUT->fill_in()
|
||||
or die;
|
||||
|
||||
# (1) They should be the same
|
||||
print +($text eq $textOUT ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# Missing: Test this feature in Safe compartments;
|
||||
# it's a totally different code path.
|
||||
# Decision: Put that into safe.t, because that file should
|
||||
# be skipped when Safe.pm is unavailable.
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
161
external/perl/Text-Template-1.46/t/04-safe.t
vendored
Normal file
161
external/perl/Text-Template-1.46/t/04-safe.t
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
BEGIN {
|
||||
eval "use Safe";
|
||||
if ($@) {
|
||||
print "1..0\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print "1..16\n";
|
||||
|
||||
if ($^O eq 'MacOS') {
|
||||
$BADOP = qq{};
|
||||
$FAILURE = q{};
|
||||
} else {
|
||||
$BADOP = qq{kill 0};
|
||||
$FAILURE = q{Program fragment at line 1 delivered error ``kill trapped by operation mask''};
|
||||
}
|
||||
|
||||
$n=1;
|
||||
$v = $v = 119;
|
||||
|
||||
$c = new Safe or die;
|
||||
|
||||
$goodtemplate = q{This should succeed: { $v }};
|
||||
$goodoutput = q{This should succeed: 119};
|
||||
|
||||
$template1 = new Text::Template ('type' => 'STRING', 'source' => $goodtemplate)
|
||||
or die;
|
||||
$template2 = new Text::Template ('type' => 'STRING', 'source' => $goodtemplate)
|
||||
or die;
|
||||
|
||||
$text1 = $template1->fill_in();
|
||||
$text2 = $template1->fill_in(SAFE => $c);
|
||||
$ERR2 = $@;
|
||||
$text3 = $template2->fill_in(SAFE => $c);
|
||||
$ERR3 = $@;
|
||||
|
||||
# (1)(2)(3) None of these should have failed.
|
||||
print +(defined $text1 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
print +(defined $text2 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
print +(defined $text3 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (4) Safe and non-safe fills of different template objects with the
|
||||
# same template text should yield the same result.
|
||||
# print +($text1 eq $text3 ? '' : 'not '), "ok $n\n";
|
||||
# (4) voided this test: it's not true, because the unsafe fill
|
||||
# uses package main, while the safe fill uses the secret safe package.
|
||||
# We could alias the secret safe package to be identical to main,
|
||||
# but that wouldn't be safe. If you want the aliasing, you have to
|
||||
# request it explicitly with `PACKAGE'.
|
||||
print "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (5) Safe and non-safe fills of the same template object
|
||||
# should yield the same result.
|
||||
# (5) voided this test for the same reason as #4.
|
||||
# print +($text1 eq $text2 ? '' : 'not '), "ok $n\n";
|
||||
print "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (6) Make sure the output was actually correct
|
||||
print +($text1 eq $goodoutput ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
$badtemplate = qq{This should fail: { $BADOP; 'NOFAIL' }};
|
||||
$badnosafeoutput = q{This should fail: NOFAIL};
|
||||
$badsafeoutput = q{This should fail: Program fragment delivered error ``kill trapped by operation mask at template line 1.''};
|
||||
|
||||
$template1 = new Text::Template ('type' => 'STRING', 'source' => $badtemplate)
|
||||
or die;
|
||||
$template2 = new Text::Template ('type' => 'STRING', 'source' => $badtemplate)
|
||||
or die;
|
||||
|
||||
$text1 = $template1->fill_in();
|
||||
$text2 = $template1->fill_in(SAFE => $c);
|
||||
$ERR2 = $@;
|
||||
$text3 = $template2->fill_in(SAFE => $c);
|
||||
$ERR3 = $@;
|
||||
$text4 = $template1->fill_in();
|
||||
|
||||
# (7)(8)(9)(10) None of these should have failed.
|
||||
print +(defined $text1 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
print +(defined $text2 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
print +(defined $text3 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
print +(defined $text4 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (11) text1 and text4 should be the same (using safe in between
|
||||
# didn't change anything.)
|
||||
print +($text1 eq $text4 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (12) text2 and text3 should be the same (same template text in different
|
||||
# objects
|
||||
print +($text2 eq $text3 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (13) text1 should yield badnosafeoutput
|
||||
print +($text1 eq $badnosafeoutput ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (14) text2 should yield badsafeoutput
|
||||
$text2 =~ s/'kill'/kill/; # 5.8.1 added quote marks around the op name
|
||||
print "# expected: <$badsafeoutput>\n# got : <$text2>\n";
|
||||
print +($text2 eq $badsafeoutput ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
$template = q{{$x=1}{$x+1}};
|
||||
|
||||
$template1 = new Text::Template ('type' => 'STRING', 'source' => $template)
|
||||
or die;
|
||||
$template2 = new Text::Template ('type' => 'STRING', 'source' => $template)
|
||||
or die;
|
||||
|
||||
$text1 = $template1->fill_in();
|
||||
$text2 = $template1->fill_in(SAFE => new Safe);
|
||||
|
||||
# (15) Do effects persist in safe compartments?
|
||||
print +($text1 eq $text2 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (16) Try the BROKEN routine in safe compartments
|
||||
sub my_broken {
|
||||
my %a = @_; $a{error} =~ s/ at.*//s;
|
||||
"OK! text:$a{text} error:$a{error} lineno:$a{lineno} arg:$a{arg}" ;
|
||||
}
|
||||
$templateB = new Text::Template (TYPE => 'STRING', SOURCE => '{die}')
|
||||
or die;
|
||||
$text1 = $templateB->fill_in(BROKEN => \&my_broken,
|
||||
BROKEN_ARG => 'barg',
|
||||
SAFE => new Safe,
|
||||
);
|
||||
$result1 = qq{OK! text:die error:Died lineno:1 arg:barg};
|
||||
print +($text1 eq $result1 ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
105
external/perl/Text-Template-1.46/t/05-safe2.t
vendored
Normal file
105
external/perl/Text-Template-1.46/t/05-safe2.t
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
BEGIN {
|
||||
eval "use Safe";
|
||||
if ($@) {
|
||||
print "1..0\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print "1..12\n";
|
||||
$n = 1;
|
||||
|
||||
$c = new Safe or die;
|
||||
|
||||
# Test handling of packages and importing.
|
||||
$c->reval('$P = "safe root"');
|
||||
$P = $P = 'main';
|
||||
$Q::P = $Q::P = 'Q';
|
||||
|
||||
# How to effectively test the gensymming?
|
||||
|
||||
$t = new Text::Template TYPE => 'STRING', SOURCE => 'package is {$P}'
|
||||
or die;
|
||||
|
||||
# (1) Default behavior: Inherit from calling package, `main' in this case.
|
||||
$text = $t->fill_in();
|
||||
print +($text eq 'package is main' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (2) When a package is specified, we should use that package instead.
|
||||
$text = $t->fill_in(PACKAGE => 'Q');
|
||||
print +($text eq 'package is Q' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (3) When no package is specified in safe mode, we should use the
|
||||
# default safe root.
|
||||
$text = $t->fill_in(SAFE => $c);
|
||||
print +($text eq 'package is safe root' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (4) When a package is specified in safe mode, we should use the
|
||||
# default safe root, after aliasing to the specified package
|
||||
$text = $t->fill_in(SAFE => $c, PACKAGE => Q);
|
||||
print +($text eq 'package is Q' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# Now let's see if hash vars are installed properly into safe templates
|
||||
$t = new Text::Template TYPE => 'STRING', SOURCE => 'hash is {$H}'
|
||||
or die;
|
||||
|
||||
# (5) First in default mode
|
||||
$text = $t->fill_in(HASH => {H => 'good5'} );
|
||||
print +($text eq 'hash is good5' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (6) Now in packages
|
||||
$text = $t->fill_in(HASH => {H => 'good6'}, PACKAGE => 'Q' );
|
||||
print +($text eq 'hash is good6' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (7) Now in the default root of the safe compartment
|
||||
$text = $t->fill_in(HASH => {H => 'good7'}, SAFE => $c );
|
||||
print +($text eq 'hash is good7' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (8) Now in the default root after aliasing to a package that
|
||||
# got the hash stuffed in
|
||||
$text = $t->fill_in(HASH => {H => 'good8'}, SAFE => $c, PACKAGE => 'Q2' );
|
||||
print +($text eq 'hash is good8' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# Now let's make sure that none of the packages leaked on each other.
|
||||
# (9) This var should NOT have been installed into the main package
|
||||
print +(defined $H ? 'not ' : ''), "ok $n\n";
|
||||
$H=$H;
|
||||
$n++;
|
||||
|
||||
# (10) good6 was overwritten in test 7, so there's nothing to test for here.
|
||||
print "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (11) this value overwrote the one from test 6.
|
||||
print +($Q::H eq 'good7' ? '' : 'not '), "ok $n\n";
|
||||
$Q::H = $Q::H;
|
||||
$n++;
|
||||
|
||||
# (12)
|
||||
print +($Q2::H eq 'good8' ? '' : 'not '), "ok $n\n";
|
||||
$Q2::H = $Q2::H;
|
||||
$n++;
|
||||
|
||||
|
||||
|
||||
39
external/perl/Text-Template-1.46/t/06-ofh.t
vendored
Normal file
39
external/perl/Text-Template-1.46/t/06-ofh.t
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
print "1..2\n";
|
||||
|
||||
$n=1;
|
||||
|
||||
$template = new Text::Template TYPE => STRING, SOURCE => q{My process ID is {$$}};
|
||||
$of = "t$$";
|
||||
END { unlink $of }
|
||||
open O, "> $of" or die;
|
||||
|
||||
$text = $template->fill_in(OUTPUT => \*O);
|
||||
|
||||
# (1) No $text should have been constructed. Return value should be true.
|
||||
print +($text eq '1' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
close O or die;
|
||||
open I, "< $of" or die;
|
||||
{ local $/; $t = <I> }
|
||||
close I;
|
||||
|
||||
# (2) The text should have been printed to the file
|
||||
print +($t eq "My process ID is $$" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
exit;
|
||||
|
||||
91
external/perl/Text-Template-1.46/t/07-safe3.t
vendored
Normal file
91
external/perl/Text-Template-1.46/t/07-safe3.t
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
|
||||
use Text::Template;
|
||||
|
||||
BEGIN {
|
||||
eval "use Safe";
|
||||
if ($@) {
|
||||
print "1..0\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print "1..3\n";
|
||||
|
||||
$n=1;
|
||||
|
||||
# Test the OUT feature with safe compartments
|
||||
|
||||
$template = q{
|
||||
This line should have a 3: {1+2}
|
||||
|
||||
This line should have several numbers:
|
||||
{ $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
|
||||
};
|
||||
|
||||
$templateOUT = q{
|
||||
This line should have a 3: { $OUT = 1+2 }
|
||||
|
||||
This line should have several numbers:
|
||||
{ foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
|
||||
};
|
||||
|
||||
$c = new Safe;
|
||||
|
||||
# Build templates from string
|
||||
$template = new Text::Template ('type' => 'STRING', 'source' => $template,
|
||||
SAFE => $c)
|
||||
or die;
|
||||
$templateOUT = new Text::Template ('type' => 'STRING', 'source' => $templateOUT,
|
||||
SAFE => $c)
|
||||
or die;
|
||||
|
||||
# Fill in templates
|
||||
$text = $template->fill_in()
|
||||
or die;
|
||||
$textOUT = $templateOUT->fill_in()
|
||||
or die;
|
||||
|
||||
# (1) They should be the same
|
||||
print +($text eq $textOUT ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (2-3) "Joel Appelbaum" <joel@orbz.com> <000701c0ac2c$aed1d6e0$0201a8c0@prime>
|
||||
# "Contrary to the documentation the $OUT variable is not always
|
||||
# undefined at the start of each program fragment. The $OUT variable
|
||||
# is never undefined after it is used once if you are using the SAFE
|
||||
# option. The result is that every fragment after the fragment that
|
||||
# $OUT was used in is replaced by the old $OUT value instead of the
|
||||
# result of the fragment. This holds true even after the
|
||||
# Text::Template object goes out of scope and a new one is created!"
|
||||
#
|
||||
# Also reported by Daini Xie.
|
||||
|
||||
{
|
||||
my $template = q{{$OUT = 'x'}y{$OUT .= 'z'}};
|
||||
my $expected = "xyz";
|
||||
my $s = Safe->new;
|
||||
my $o = Text::Template->new(type => 'string',
|
||||
source => $template,
|
||||
);
|
||||
for (1..2) {
|
||||
my $r = $o->fill_in(SAFE => $s);
|
||||
if ($r ne $expected) {
|
||||
print "not ok $n # <$r>\n";
|
||||
} else {
|
||||
print "ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
75
external/perl/Text-Template-1.46/t/08-exported.t
vendored
Normal file
75
external/perl/Text-Template-1.46/t/08-exported.t
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template 'fill_in_file', 'fill_in_string';
|
||||
|
||||
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;
|
||||
|
||||
print "1..6\n";
|
||||
|
||||
$n=1;
|
||||
$Q::n = $Q::n = 119;
|
||||
|
||||
# (1) Test fill_in_string
|
||||
$out = fill_in_string('The value of $n is {$n}.', PACKAGE => 'Q' );
|
||||
print +($out eq 'The value of $n is 119.' ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (2) Test fill_in_file
|
||||
$TEMPFILE = "tt$$";
|
||||
open F, "> $TEMPFILE" or die "Couldn't open test file: $!; aborting";
|
||||
print F 'The value of $n is {$n}.', "\n";
|
||||
close F or die "Couldn't write test file: $!; aborting";
|
||||
$R::n = $R::n = 8128;
|
||||
|
||||
$out = fill_in_file($TEMPFILE, PACKAGE => 'R');
|
||||
print +($out eq "The value of \$n is 8128.\n" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (3) Jonathan Roy reported this bug:
|
||||
open F, "> $TEMPFILE" or die "Couldn't open test file: $!; aborting";
|
||||
print F "With a message here? [% \$var %]\n";
|
||||
close F or die "Couldn't close test file: $!; aborting";
|
||||
$out = fill_in_file($TEMPFILE, DELIMITERS => ['[%', '%]'],
|
||||
HASH => { "var" => \"It is good!" });
|
||||
print +($out eq "With a message here? It is good!\n" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (4) It probably occurs in fill_this_in also:
|
||||
$out =
|
||||
Text::Template->fill_this_in("With a message here? [% \$var %]\n",
|
||||
DELIMITERS => ['[%', '%]'],
|
||||
HASH => { "var" => \"It is good!" });
|
||||
print +($out eq "With a message here? It is good!\n" ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (5) This test failed in 1.25. It was supplied by Donald L. Greer Jr.
|
||||
# Note that it's different from (1) in that there's no explicit
|
||||
# package=> argument.
|
||||
use vars qw($string $foo $r);
|
||||
$string='Hello {$foo}';
|
||||
$foo="Don";
|
||||
$r = fill_in_string($string);
|
||||
print (($r eq 'Hello Don' ? '' : 'not '), 'ok ', $n++, "\n");
|
||||
|
||||
# (6) This test failed in 1.25. It's a variation on (5)
|
||||
package Q2;
|
||||
use Text::Template 'fill_in_string';
|
||||
use vars qw($string $foo $r);
|
||||
$string='Hello {$foo}';
|
||||
$foo="Don";
|
||||
$r = fill_in_string($string);
|
||||
print (($r eq 'Hello Don' ? '' : 'not '), 'ok ', $main::n++, "\n");
|
||||
|
||||
package main;
|
||||
|
||||
END { $TEMPFILE && unlink $TEMPFILE }
|
||||
|
||||
exit;
|
||||
|
||||
63
external/perl/Text-Template-1.46/t/09-error.t
vendored
Normal file
63
external/perl/Text-Template-1.46/t/09-error.t
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
#!perl
|
||||
#
|
||||
# test apparatus for Text::Template module
|
||||
# still incomplete.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
print "1..5\n";
|
||||
$n = 1;
|
||||
|
||||
# (1-2) Missing source
|
||||
eval {
|
||||
Text::Template->new();
|
||||
};
|
||||
unless ($@ =~ /^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/) {
|
||||
print STDERR $@;
|
||||
print "not ";
|
||||
}
|
||||
print "ok $n\n";
|
||||
$n++;
|
||||
|
||||
eval {
|
||||
Text::Template->new(TYPE => 'FILE');
|
||||
};
|
||||
if ($@ =~ /^\QUsage: Text::Template::new(TYPE => ..., SOURCE => ...)/) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print STDERR $@;
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (3) Invalid type
|
||||
eval {
|
||||
Text::Template->new(TYPE => 'wlunch', SOURCE => 'fish food');
|
||||
};
|
||||
if ($@ =~ /^\QIllegal value `WLUNCH' for TYPE parameter/) {
|
||||
print "ok $n\n";
|
||||
} else {
|
||||
print STDERR $@;
|
||||
print "not ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
|
||||
# (4-5) File does not exist
|
||||
my $o = Text::Template->new(TYPE => 'file',
|
||||
SOURCE => 'this file does not exist');
|
||||
print $o ? "not ok $n\n" : "ok $n\n";
|
||||
$n++;
|
||||
print defined($Text::Template::ERROR)
|
||||
&& $Text::Template::ERROR =~ /^Couldn't open file/
|
||||
? "ok $n\n" : "not ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
99
external/perl/Text-Template-1.46/t/10-delimiters.t
vendored
Normal file
99
external/perl/Text-Template-1.46/t/10-delimiters.t
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
#!perl
|
||||
#
|
||||
# Tests for user-specified delimiter functions
|
||||
# These tests first appeared in version 1.20.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
print "1..18\n";
|
||||
$n = 1;
|
||||
|
||||
# (1) Try a simple delimiter: <<..>>
|
||||
# First with the delimiters specified at object creation time
|
||||
$V = $V = 119;
|
||||
$template = q{The value of $V is <<$V>>.};
|
||||
$result = q{The value of $V is 119.};
|
||||
$template1 = Text::Template->new(TYPE => STRING,
|
||||
SOURCE => $template,
|
||||
DELIMITERS => ['<<', '>>']
|
||||
)
|
||||
or die "Couldn't construct template object: $Text::Template::ERROR; aborting";
|
||||
$text = $template1->fill_in();
|
||||
print +($text eq $result ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (2) Now with delimiter choice deferred until fill-in time.
|
||||
$template1 = Text::Template->new(TYPE => STRING, SOURCE => $template);
|
||||
$text = $template1->fill_in(DELIMITERS => ['<<', '>>']);
|
||||
print +($text eq $result ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (3) Now we'll try using regex metacharacters
|
||||
# First with the delimiters specified at object creation time
|
||||
$template = q{The value of $V is [$V].};
|
||||
$template1 = Text::Template->new(TYPE => STRING,
|
||||
SOURCE => $template,
|
||||
DELIMITERS => ['[', ']']
|
||||
)
|
||||
or die "Couldn't construct template object: $Text::Template::ERROR; aborting";
|
||||
$text = $template1->fill_in();
|
||||
print +($text eq $result ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
# (4) Now with delimiter choice deferred until fill-in time.
|
||||
$template1 = Text::Template->new(TYPE => STRING, SOURCE => $template);
|
||||
$text = $template1->fill_in(DELIMITERS => ['[', ']']);
|
||||
print +($text eq $result ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
|
||||
|
||||
|
||||
# (5-18) Make sure \ is working properly
|
||||
# (That is to say, it is ignored.)
|
||||
# These tests are similar to those in 01-basic.t.
|
||||
my @tests = ('{""}' => '', # (5)
|
||||
|
||||
# Backslashes don't matter
|
||||
'{"}"}' => undef,
|
||||
'{"\\}"}' => undef, # One backslash
|
||||
'{"\\\\}"}' => undef, # Two backslashes
|
||||
'{"\\\\\\}"}' => undef, # Three backslashes
|
||||
'{"\\\\\\\\}"}' => undef, # Four backslashes (10)
|
||||
'{"\\\\\\\\\\}"}' => undef, # Five backslashes
|
||||
|
||||
# Backslashes are always passed directly to Perl
|
||||
'{"x20"}' => 'x20',
|
||||
'{"\\x20"}' => ' ', # One backslash
|
||||
'{"\\\\x20"}' => '\\x20', # Two backslashes
|
||||
'{"\\\\\\x20"}' => '\\ ', # Three backslashes (15)
|
||||
'{"\\\\\\\\x20"}' => '\\\\x20', # Four backslashes
|
||||
'{"\\\\\\\\\\x20"}' => '\\\\ ', # Five backslashes
|
||||
'{"\\x20\\}"}' => undef, # (18)
|
||||
);
|
||||
|
||||
my $i;
|
||||
for ($i=0; $i<@tests; $i+=2) {
|
||||
my $tmpl = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => $tests[$i],
|
||||
DELIMITERS => ['{', '}'],
|
||||
);
|
||||
my $text = $tmpl->fill_in;
|
||||
my $result = $tests[$i+1];
|
||||
my $ok = (! defined $text && ! defined $result
|
||||
|| $text eq $result);
|
||||
unless ($ok) {
|
||||
print STDERR "($n) expected .$result., got .$text.\n";
|
||||
}
|
||||
print +($ok ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
94
external/perl/Text-Template-1.46/t/11-prepend.t
vendored
Normal file
94
external/perl/Text-Template-1.46/t/11-prepend.t
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
#!perl
|
||||
#
|
||||
# Tests for PREPEND features
|
||||
# These tests first appeared in version 1.22.
|
||||
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
print "1..9\n";
|
||||
my $n = 1;
|
||||
|
||||
@Emptyclass1::ISA = 'Text::Template';
|
||||
@Emptyclass2::ISA = 'Text::Template';
|
||||
|
||||
my $tin = q{The value of $foo is: {$foo}};
|
||||
|
||||
Text::Template->always_prepend(q{$foo = "global"});
|
||||
|
||||
$tmpl1 = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
);
|
||||
|
||||
$tmpl2 = Text::Template->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
PREPEND => q{$foo = "template"},
|
||||
);
|
||||
|
||||
$tmpl1->compile;
|
||||
$tmpl2->compile;
|
||||
|
||||
$t1 = $tmpl1->fill_in(PACKAGE => 'T1');
|
||||
$t2 = $tmpl2->fill_in(PACKAGE => 'T2');
|
||||
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T3');
|
||||
|
||||
($t1 eq 'The value of $foo is: global') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t2 eq 'The value of $foo is: template') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t3 eq 'The value of $foo is: fillin') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
|
||||
Emptyclass1->always_prepend(q{$foo = 'Emptyclass global';});
|
||||
$tmpl1 = Emptyclass1->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
);
|
||||
|
||||
$tmpl2 = Emptyclass1->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
PREPEND => q{$foo = "template"},
|
||||
);
|
||||
|
||||
$tmpl1->compile;
|
||||
$tmpl2->compile;
|
||||
|
||||
$t1 = $tmpl1->fill_in(PACKAGE => 'T4');
|
||||
$t2 = $tmpl2->fill_in(PACKAGE => 'T5');
|
||||
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');
|
||||
|
||||
($t1 eq 'The value of $foo is: Emptyclass global') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t2 eq 'The value of $foo is: template') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t3 eq 'The value of $foo is: fillin') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
|
||||
$tmpl1 = Emptyclass2->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
);
|
||||
|
||||
$tmpl2 = Emptyclass2->new(TYPE => 'STRING',
|
||||
SOURCE => $tin,
|
||||
PREPEND => q{$foo = "template"},
|
||||
);
|
||||
|
||||
$tmpl1->compile;
|
||||
$tmpl2->compile;
|
||||
|
||||
$t1 = $tmpl1->fill_in(PACKAGE => 'T4');
|
||||
$t2 = $tmpl2->fill_in(PACKAGE => 'T5');
|
||||
$t3 = $tmpl2->fill_in(PREPEND => q{$foo = "fillin"}, PACKAGE => 'T6');
|
||||
|
||||
($t1 eq 'The value of $foo is: global') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t2 eq 'The value of $foo is: template') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
($t3 eq 'The value of $foo is: fillin') or print "not ";
|
||||
print "ok $n\n"; $n++;
|
||||
|
||||
|
||||
52
external/perl/Text-Template-1.46/t/12-preprocess.t
vendored
Normal file
52
external/perl/Text-Template-1.46/t/12-preprocess.t
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
#!perl
|
||||
#
|
||||
# Tests for PREPROCESSOR features
|
||||
# These tests first appeared in version 1.25.
|
||||
|
||||
use Text::Template::Preprocess;
|
||||
|
||||
die "This is the test program for Text::Template::Preprocess version 1.46.
|
||||
You are using version $Text::Template::Preprocess::VERSION instead.
|
||||
That does not make sense.\n
|
||||
Aborting"
|
||||
unless $Text::Template::Preprocess::VERSION == 1.46;
|
||||
|
||||
$TMPFILE = "tt$$";
|
||||
|
||||
print "1..8\n";
|
||||
my $n = 1;
|
||||
|
||||
my $py = sub { tr/x/y/ };
|
||||
my $pz = sub { tr/x/z/ };
|
||||
|
||||
my $t = 'xxx The value of $x is {$x}';
|
||||
my $outx = 'xxx The value of $x is 119';
|
||||
my $outy = 'yyy The value of $y is 23';
|
||||
my $outz = 'zzz The value of $z is 5';
|
||||
open TF, "> $TMPFILE" or die "Couldn't open test file: $!; aborting";
|
||||
print TF $t;
|
||||
close TF;
|
||||
|
||||
@result = ($outx, $outy, $outz, $outz);
|
||||
for my $trial (1, 0) {
|
||||
for my $test (0 .. 3) {
|
||||
my $tmpl;
|
||||
if ($trial == 0) {
|
||||
$tmpl = new Text::Template::Preprocess
|
||||
(TYPE => 'STRING', SOURCE => $t) or die;
|
||||
} else {
|
||||
open TF, "< $TMPFILE" or die "Couldn't open test file: $!; aborting";
|
||||
$tmpl = new Text::Template::Preprocess
|
||||
(TYPE => 'FILEHANDLE', SOURCE => \*TF) or die;
|
||||
}
|
||||
$tmpl->preprocessor($py) if ($test & 1) == 1;
|
||||
my @args = ((($test & 2) == 2) ? (PREPROCESSOR => $pz) : ());
|
||||
my $o = $tmpl->fill_in(@args,
|
||||
HASH => {x => 119, 'y' => 23, z => 5});
|
||||
# print STDERR "$o/$result[$test]\n";
|
||||
print +(($o eq $result[$test]) ? '' : 'not '), "ok $n\n";
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
|
||||
unlink $TMPFILE;
|
||||
119
external/perl/Text-Template-1.46/t/13-taint.t
vendored
Normal file
119
external/perl/Text-Template-1.46/t/13-taint.t
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
#!perl -T
|
||||
# Tests for taint-mode features
|
||||
|
||||
use lib 'blib/lib';
|
||||
use Text::Template;
|
||||
|
||||
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;
|
||||
|
||||
my $r = int(rand(10000));
|
||||
my $file = "tt$r";
|
||||
|
||||
# makes its arguments tainted
|
||||
sub taint {
|
||||
for (@_) {
|
||||
$_ .= substr($0,0,0); # LOD
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "1..21\n";
|
||||
|
||||
my $n =1;
|
||||
print "ok ", $n++, "\n";
|
||||
|
||||
my $template = 'The value of $n is {$n}.';
|
||||
|
||||
open T, "> $file" or die "Couldn't write temporary file $file: $!";
|
||||
print T $template, "\n";
|
||||
close T or die "Couldn't finish temporary file $file: $!";
|
||||
|
||||
sub should_fail {
|
||||
my $obj = Text::Template->new(@_);
|
||||
eval {$obj->fill_in()};
|
||||
if ($@) {
|
||||
print "ok $n # $@\n";
|
||||
} else {
|
||||
print "not ok $n # (didn't fail)\n";
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
|
||||
sub should_work {
|
||||
my $obj = Text::Template->new(@_);
|
||||
eval {$obj->fill_in()};
|
||||
if ($@) {
|
||||
print "not ok $n # $@\n";
|
||||
} else {
|
||||
print "ok $n\n";
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
|
||||
sub should_be_tainted {
|
||||
if (Text::Template::_is_clean($_[0])) {
|
||||
print "not ok $n\n"; $n++; return;
|
||||
}
|
||||
print "ok $n\n"; $n++; return;
|
||||
}
|
||||
|
||||
sub should_be_clean {
|
||||
unless (Text::Template::_is_clean($_[0])) {
|
||||
print "not ok $n\n"; $n++; return;
|
||||
}
|
||||
print "ok $n\n"; $n++; return;
|
||||
}
|
||||
|
||||
# Tainted filename should die with and without UNTAINT option
|
||||
# untainted filename should die without UNTAINT option
|
||||
# filehandle should die without UNTAINT option
|
||||
# string and array with tainted data should die either way
|
||||
|
||||
# (2)-(7)
|
||||
my $tfile = $file;
|
||||
taint($tfile);
|
||||
should_be_tainted($tfile);
|
||||
should_be_clean($file);
|
||||
should_fail TYPE => 'file', SOURCE => $tfile;
|
||||
should_fail TYPE => 'file', SOURCE => $tfile, UNTAINT => 1;
|
||||
should_fail TYPE => 'file', SOURCE => $file;
|
||||
should_work TYPE => 'file', SOURCE => $file, UNTAINT => 1;
|
||||
|
||||
# (8-9)
|
||||
open H, "< $file" or die "Couldn't open $file for reading: $!; aborting";
|
||||
should_fail TYPE => 'filehandle', SOURCE => \*H;
|
||||
close H;
|
||||
open H, "< $file" or die "Couldn't open $file for reading: $!; aborting";
|
||||
should_work TYPE => 'filehandle', SOURCE => \*H, UNTAINT => 1;
|
||||
close H;
|
||||
|
||||
# (10-15)
|
||||
my $ttemplate = $template;
|
||||
taint($ttemplate);
|
||||
should_be_tainted($ttemplate);
|
||||
should_be_clean($template);
|
||||
should_fail TYPE => 'string', SOURCE => $ttemplate;
|
||||
should_fail TYPE => 'string', SOURCE => $ttemplate, UNTAINT => 1;
|
||||
should_work TYPE => 'string', SOURCE => $template;
|
||||
should_work TYPE => 'string', SOURCE => $template, UNTAINT => 1;
|
||||
|
||||
# (16-19)
|
||||
my $array = [ $template ];
|
||||
my $tarray = [ $ttemplate ];
|
||||
should_fail TYPE => 'array', SOURCE => $tarray;
|
||||
should_fail TYPE => 'array', SOURCE => $tarray, UNTAINT => 1;
|
||||
should_work TYPE => 'array', SOURCE => $array;
|
||||
should_work TYPE => 'array', SOURCE => $array, UNTAINT => 1;
|
||||
|
||||
# (20-21) Test _unconditionally_untaint utility function
|
||||
Text::Template::_unconditionally_untaint($ttemplate);
|
||||
should_be_clean($ttemplate);
|
||||
Text::Template::_unconditionally_untaint($tfile);
|
||||
should_be_clean($tfile);
|
||||
|
||||
END { unlink $file }
|
||||
|
||||
82
external/perl/Text-Template-1.46/t/14-broken.t
vendored
Normal file
82
external/perl/Text-Template-1.46/t/14-broken.t
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
#!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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user