Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a0723b2
  • /
  • external
  • /
  • perl
  • /
  • Text-Template-1.56
  • /
  • t
  • /
  • warnings.t
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:a20a640b17d92a69388e27d5d6b7c2feb4630b44
directory badge Iframe embedding
swh:1:dir:7f3413dd469356106299d911badbf763182377dc
warnings.t
#!perl

use strict;
use warnings;
use Text::Template;

# Minimum Test::More version; 0.94+ is required for `done_testing`
BEGIN {
    unless (eval { require Test::More; "$Test::More::VERSION" >= 0.94; }) {
        Test::More::plan(skip_all => '[ Test::More v0.94+ ] is required for testing');
    }

    Test::More->import;

    # Non-CORE module(s)
    unless (eval { require Test::Warnings; 1; }) {
        plan(skip_all => '[ Test::Warnings ] is required for testing');
    }

    Test::Warnings->import;
}

my $template = <<'EOT';
{{
if ($good =~ /good/) {
    'This template should not produce warnings.'.$bad;
}
}}
EOT

$template = Text::Template->new(type => 'STRING', source => $template);
isa_ok $template, 'Text::Template';

my $result = $template->fill_in(HASH => { good => 'good' });

$result =~ s/(?:^\s+)|(?:\s+$)//gs;
is $result, 'This template should not produce warnings.';

# see https://github.com/mschout/perl-text-template/issues/10
$template = Text::Template->new(type => 'STRING', package => 'MY', source => '');
$template->fill_in(package => 'MY', hash => { include => sub { 'XX' } });

$template = Text::Template->new(type => 'STRING', package => 'MY', source => '');
$template->fill_in(package => 'MY', hash => { include => sub { 'XX' } });

done_testing;

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top