[Templates-cvs] cvs commit: TT3/t/directive my.t

cvs@template-toolkit.org cvs@template-toolkit.org
Wed, 01 Dec 2004 11:17:37 +0000


cvs         04/12/01 11:17:37

  Added:       t/directive my.t
  Log:
  * added (non-)tests for MY directive
  
  Revision  Changes    Path
  1.1                  TT3/t/directive/my.t
  
  Index: my.t
  ===================================================================
  #============================================================= -*-perl-*-
  #
  # t/directive/my.t
  #
  # Test the Template::Directive::My directive.
  #
  # Written by Andy Wardley <abw@wardley.org>
  #
  # This is free software; you can redistribute it and/or modify it
  # under the same terms as Perl itself.
  #
  # $Id: my.t,v 1.1 2004/12/01 11:17:36 abw Exp $
  #
  #========================================================================
  
  use strict;
  use warnings;
  
  use lib qw( ./lib ../lib ../../lib );
  use Template::TT3::Compiler;
  use Template::Directive::My;
  use Template::Test skip_all => 'test not working yet', tests => 12, import => ':all';
  
  our $DEBUG = 
  $Template::Directive::My::DEBUG =
  grep(/^--?d(ebug)?/, @ARGV);
  
  
  my $compiler = Template::TT3::Compiler->new()
      || die Template::TT3::Compiler->error();
  
  test_expect({
      handler => \&parse, 
      debug   => $DEBUG,
  });
  
  sub parse {
      my $test  = shift;
      my $input = $test->{ input };
  
      return $compiler->compile(\$input, name => $test->{ name })
          || '<ERROR:' . $compiler->error() . '>';
  }
  
  __END__
  
  -- test set --
  [% MY x = 10
        y = { foo => z, bar => x }
  %]
  [% x %]
  -- expect --
  set stuff
  
  __END__
  
  # Local Variables:
  # mode: perl
  # perl-indent-level: 4
  # indent-tabs-mode: nil
  # End:
  #
  # vim: expandtab shiftwidth=4: