xref: /freebsd-src/crypto/openssl/external/perl/Text-Template-1.56/t/ofh.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 Schubertuse strict;
7*e0c4386eSCy Schubertuse warnings;
8*e0c4386eSCy Schubertuse Test::More tests => 3;
9*e0c4386eSCy Schubertuse File::Temp;
10*e0c4386eSCy Schubert
11*e0c4386eSCy Schubertuse_ok 'Text::Template' or exit 1;
12*e0c4386eSCy Schubert
13*e0c4386eSCy Schubertmy $template = Text::Template->new(
14*e0c4386eSCy Schubert    TYPE   => 'STRING',
15*e0c4386eSCy Schubert    SOURCE => q{My process ID is {$$}});
16*e0c4386eSCy Schubert
17*e0c4386eSCy Schubertmy $of = File::Temp->new;
18*e0c4386eSCy Schubert
19*e0c4386eSCy Schubertmy $text = $template->fill_in(OUTPUT => $of);
20*e0c4386eSCy Schubert
21*e0c4386eSCy Schubert# (1) No $text should have been constructed.  Return value should be true.
22*e0c4386eSCy Schubertis $text, '1';
23*e0c4386eSCy Schubert
24*e0c4386eSCy Schubertclose $of or die "close(): $!";
25*e0c4386eSCy Schubert
26*e0c4386eSCy Schubertopen my $ifh, '<', $of->filename or die "open($of): $!";
27*e0c4386eSCy Schubert
28*e0c4386eSCy Schubertmy $t;
29*e0c4386eSCy Schubert{ local $/; $t = <$ifh> }
30*e0c4386eSCy Schubertclose $ifh;
31*e0c4386eSCy Schubert
32*e0c4386eSCy Schubert# (2) The text should have been printed to the file
33*e0c4386eSCy Schubertis $t, "My process ID is $$";
34