03-out.t 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!perl
  2. #
  3. # test apparatus for Text::Template module
  4. # still incomplete.
  5. #
  6. use Text::Template;
  7. die "This is the test program for Text::Template version 1.46
  8. You are using version $Text::Template::VERSION instead.
  9. That does not make sense.\n
  10. Aborting"
  11. unless $Text::Template::VERSION == 1.46;
  12. print "1..1\n";
  13. $n=1;
  14. $template = q{
  15. This line should have a 3: {1+2}
  16. This line should have several numbers:
  17. { $t = ''; foreach $n (1 .. 20) { $t .= $n . ' ' } $t }
  18. };
  19. $templateOUT = q{
  20. This line should have a 3: { $OUT = 1+2 }
  21. This line should have several numbers:
  22. { foreach $n (1 .. 20) { $OUT .= $n . ' ' } }
  23. };
  24. # Build templates from string
  25. $template = new Text::Template ('type' => 'STRING', 'source' => $template)
  26. or die;
  27. $templateOUT = new Text::Template ('type' => 'STRING', 'source' => $templateOUT)
  28. or die;
  29. # Fill in templates
  30. $text = $template->fill_in()
  31. or die;
  32. $textOUT = $templateOUT->fill_in()
  33. or die;
  34. # (1) They should be the same
  35. print +($text eq $textOUT ? '' : 'not '), "ok $n\n";
  36. $n++;
  37. # Missing: Test this feature in Safe compartments;
  38. # it's a totally different code path.
  39. # Decision: Put that into safe.t, because that file should
  40. # be skipped when Safe.pm is unavailable.
  41. exit;