out.t 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!perl
  2. #
  3. # test apparatus for Text::Template module
  4. # still incomplete.
  5. #
  6. use strict;
  7. use warnings;
  8. use Test::More tests => 4;
  9. use_ok 'Text::Template' or exit 1;
  10. my $templateIN = q{
  11. This line should have a 3: {1+2}
  12. This line should have several numbers:
  13. { $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
  14. };
  15. my $templateOUT = q{
  16. This line should have a 3: { $OUT = 1+2 }
  17. This line should have several numbers:
  18. { foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
  19. };
  20. # Build templates from string
  21. my $template = Text::Template->new('type' => 'STRING', 'source' => $templateIN);
  22. isa_ok $template, 'Text::Template';
  23. $templateOUT = Text::Template->new('type' => 'STRING', 'source' => $templateOUT);
  24. isa_ok $templateOUT, 'Text::Template';
  25. # Fill in templates
  26. my $text = $template->fill_in();
  27. my $textOUT = $templateOUT->fill_in();
  28. # (1) They should be the same
  29. is $text, $textOUT;
  30. # Missing: Test this feature in Safe compartments;
  31. # it's a totally different code path.
  32. # Decision: Put that into safe.t, because that file should
  33. # be skipped when Safe.pm is unavailable.
  34. exit;