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

  • b255ef9
  • /
  • external
  • /
  • perl
  • /
  • Text-Template-1.46
  • /
  • t
  • /
  • 14-broken.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:d362395cfbc7fd73ceb8646a11b3d89e0a95845b
directory badge Iframe embedding
swh:1:dir:1d01bfba8f6870b87d99bb3d4729d0941a61b5f3
14-broken.t
#!perl
# test apparatus for Text::Template module

use Text::Template;

print "1..5\n";

$n=1;

die "This is the test program for Text::Template version 1.46.
You are using version $Text::Template::VERSION instead.
That does not make sense.\n
Aborting"
  unless $Text::Template::VERSION == 1.46;

# (1) basic error delivery
{ my $r = Text::Template->new(TYPE => 'string',
                              SOURCE => '{1/0}',
                             )->fill_in();
  if ($r eq q{Program fragment delivered error ``Illegal division by zero at template line 1.''}) {
    print "ok $n\n";
  } else {
    print "not ok $n\n# $r\n";
  }
  $n++;
}

# (2) BROKEN sub called in ->new?
{ my $r = Text::Template->new(TYPE => 'string',
                              SOURCE => '{1/0}',
                              BROKEN => sub {'---'},
                             )->fill_in();
  if ($r eq q{---}) {
    print "ok $n\n";
  } else {
    print "not ok $n\n# $r\n";
  }
  $n++;
}

# (3) BROKEN sub called in ->fill_in?
{ my $r = Text::Template->new(TYPE => 'string',
                              SOURCE => '{1/0}',
                             )->fill_in(BROKEN => sub {'---'});
  if ($r eq q{---}) {
    print "ok $n\n";
  } else {
    print "not ok $n\n# $r\n";
  }
  $n++;
}

# (4) BROKEN sub passed correct args when called in ->new?
{ my $r = Text::Template->new(TYPE => 'string',
                              SOURCE => '{1/0}',
                              BROKEN => sub { my %a = @_;
                                qq{$a{lineno},$a{error},$a{text}}
                              },
                             )->fill_in();
  if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
    print "ok $n\n";
  } else {
    print "not ok $n\n# $r\n";
  }
  $n++;
}

# (5) BROKEN sub passed correct args when called in ->fill_in?
{ my $r = Text::Template->new(TYPE => 'string',
                              SOURCE => '{1/0}',
                             )->fill_in(BROKEN => 
                                        sub { my %a = @_;
                                              qq{$a{lineno},$a{error},$a{text}}
                                            });
  if ($r eq qq{1,Illegal division by zero at template line 1.\n,1/0}) {
    print "ok $n\n";
  } else {
    print "not ok $n\n# $r\n";
  }
  $n++;
}

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

back to top