#============================================================= -*-perl-*- # # t/format.t # # Template script testing the format plugin. # # Written by Andy Wardley # # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved. # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd. # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id$ # #======================================================================== use strict; use lib qw( ./lib ../lib ); use Template qw( :status ); use Template::Test; $^W = 1; $Template::Test::DEBUG = 0; $Template::Test::PRESERVE = 1; my ($a, $b, $c, $d) = qw( alpha bravo charlie delta ); my $params = { 'a' => $a, 'b' => $b, 'c' => $c, 'd' => $d, }; test_expect(\*DATA, { INTERPOLATE => 1, POST_CHOMP => 1 }, $params); #------------------------------------------------------------------------ # test input #------------------------------------------------------------------------ __DATA__ [% USE format %] [% bold = format('%s') %] [% ital = format('%s') %] [% bold('heading') +%] [% ital('author') +%] ${ ital('affil.') } [% bold('footing') +%] $bold -- expect -- heading author affil. footing -- test -- [% USE format('
  • %s') %] [% FOREACH item = [ a b c d ] %] [% format(item) +%] [% END %] -- expect --
  • alpha
  • bravo
  • charlie
  • delta -- test -- [% USE bold = format("%s") %] [% USE ital = format("%s") %] [% bold('This is bold') +%] [% ital('This is italic') +%] -- expect -- This is bold This is italic -- test -- [% USE padleft = format('%-*s') %] [% USE padright = format('%*s') %] [% padleft(10, a) %]-[% padright(10, b) %] -- expect -- alpha - bravo