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