xref: /freebsd-src/crypto/openssl/external/perl/Text-Template-1.56/t/out.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#!perl
2*e0c4386eSCy Schubert#
3*e0c4386eSCy Schubert# test apparatus for Text::Template module
4*e0c4386eSCy Schubert# still incomplete.
5*e0c4386eSCy Schubert#
6*e0c4386eSCy Schubert
7*e0c4386eSCy Schubertuse strict;
8*e0c4386eSCy Schubertuse warnings;
9*e0c4386eSCy Schubertuse Test::More tests => 4;
10*e0c4386eSCy Schubert
11*e0c4386eSCy Schubertuse_ok 'Text::Template' or exit 1;
12*e0c4386eSCy Schubert
13*e0c4386eSCy Schubertmy $templateIN = q{
14*e0c4386eSCy SchubertThis line should have a 3: {1+2}
15*e0c4386eSCy Schubert
16*e0c4386eSCy SchubertThis line should have several numbers:
17*e0c4386eSCy Schubert{ $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
18*e0c4386eSCy Schubert};
19*e0c4386eSCy Schubert
20*e0c4386eSCy Schubertmy $templateOUT = q{
21*e0c4386eSCy SchubertThis line should have a 3: { $OUT = 1+2 }
22*e0c4386eSCy Schubert
23*e0c4386eSCy SchubertThis line should have several numbers:
24*e0c4386eSCy Schubert{ foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
25*e0c4386eSCy Schubert};
26*e0c4386eSCy Schubert
27*e0c4386eSCy Schubert# Build templates from string
28*e0c4386eSCy Schubertmy $template = Text::Template->new('type' => 'STRING', 'source' => $templateIN);
29*e0c4386eSCy Schubertisa_ok $template, 'Text::Template';
30*e0c4386eSCy Schubert
31*e0c4386eSCy Schubert$templateOUT = Text::Template->new('type' => 'STRING', 'source' => $templateOUT);
32*e0c4386eSCy Schubertisa_ok $templateOUT, 'Text::Template';
33*e0c4386eSCy Schubert
34*e0c4386eSCy Schubert# Fill in templates
35*e0c4386eSCy Schubertmy $text    = $template->fill_in();
36*e0c4386eSCy Schubertmy $textOUT = $templateOUT->fill_in();
37*e0c4386eSCy Schubert
38*e0c4386eSCy Schubert# (1) They should be the same
39*e0c4386eSCy Schubertis $text, $textOUT;
40*e0c4386eSCy Schubert
41*e0c4386eSCy Schubert# Missing:  Test this feature in Safe compartments;
42*e0c4386eSCy Schubert# it's a totally different code path.
43*e0c4386eSCy Schubert# Decision: Put that into safe.t, because that file should
44*e0c4386eSCy Schubert# be skipped when Safe.pm is unavailable.
45*e0c4386eSCy Schubert
46*e0c4386eSCy Schubertexit;
47