ofh.t 665 B

123456789101112131415161718192021222324252627282930313233
  1. #!perl
  2. #
  3. # test apparatus for Text::Template module
  4. # still incomplete.
  5. use strict;
  6. use warnings;
  7. use Test::More tests => 3;
  8. use File::Temp;
  9. use_ok 'Text::Template' or exit 1;
  10. my $template = Text::Template->new(
  11. TYPE => 'STRING',
  12. SOURCE => q{My process ID is {$$}});
  13. my $of = File::Temp->new;
  14. my $text = $template->fill_in(OUTPUT => $of);
  15. # (1) No $text should have been constructed. Return value should be true.
  16. is $text, '1';
  17. close $of or die "close(): $!";
  18. open my $ifh, '<', $of->filename or die "open($of): $!";
  19. my $t;
  20. { local $/; $t = <$ifh> }
  21. close $ifh;
  22. # (2) The text should have been printed to the file
  23. is $t, "My process ID is $$";