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