xref: /freebsd/crypto/openssl/external/perl/Text-Template-1.56/t/warnings.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#!perl
2*e0c4386eSCy Schubert
3*e0c4386eSCy Schubertuse strict;
4*e0c4386eSCy Schubertuse warnings;
5*e0c4386eSCy Schubertuse Text::Template;
6*e0c4386eSCy Schubert
7*e0c4386eSCy Schubert# Minimum Test::More version; 0.94+ is required for `done_testing`
8*e0c4386eSCy SchubertBEGIN {
9*e0c4386eSCy Schubert    unless (eval { require Test::More; "$Test::More::VERSION" >= 0.94; }) {
10*e0c4386eSCy Schubert        Test::More::plan(skip_all => '[ Test::More v0.94+ ] is required for testing');
11*e0c4386eSCy Schubert    }
12*e0c4386eSCy Schubert
13*e0c4386eSCy Schubert    Test::More->import;
14*e0c4386eSCy Schubert
15*e0c4386eSCy Schubert    # Non-CORE module(s)
16*e0c4386eSCy Schubert    unless (eval { require Test::Warnings; 1; }) {
17*e0c4386eSCy Schubert        plan(skip_all => '[ Test::Warnings ] is required for testing');
18*e0c4386eSCy Schubert    }
19*e0c4386eSCy Schubert
20*e0c4386eSCy Schubert    Test::Warnings->import;
21*e0c4386eSCy Schubert}
22*e0c4386eSCy Schubert
23*e0c4386eSCy Schubertmy $template = <<'EOT';
24*e0c4386eSCy Schubert{{
25*e0c4386eSCy Schubertif ($good =~ /good/) {
26*e0c4386eSCy Schubert    'This template should not produce warnings.'.$bad;
27*e0c4386eSCy Schubert}
28*e0c4386eSCy Schubert}}
29*e0c4386eSCy SchubertEOT
30*e0c4386eSCy Schubert
31*e0c4386eSCy Schubert$template = Text::Template->new(type => 'STRING', source => $template);
32*e0c4386eSCy Schubertisa_ok $template, 'Text::Template';
33*e0c4386eSCy Schubert
34*e0c4386eSCy Schubertmy $result = $template->fill_in(HASH => { good => 'good' });
35*e0c4386eSCy Schubert
36*e0c4386eSCy Schubert$result =~ s/(?:^\s+)|(?:\s+$)//gs;
37*e0c4386eSCy Schubertis $result, 'This template should not produce warnings.';
38*e0c4386eSCy Schubert
39*e0c4386eSCy Schubert# see https://github.com/mschout/perl-text-template/issues/10
40*e0c4386eSCy Schubert$template = Text::Template->new(type => 'STRING', package => 'MY', source => '');
41*e0c4386eSCy Schubert$template->fill_in(package => 'MY', hash => { include => sub { 'XX' } });
42*e0c4386eSCy Schubert
43*e0c4386eSCy Schubert$template = Text::Template->new(type => 'STRING', package => 'MY', source => '');
44*e0c4386eSCy Schubert$template->fill_in(package => 'MY', hash => { include => sub { 'XX' } });
45*e0c4386eSCy Schubert
46*e0c4386eSCy Schubertdone_testing;
47