[Templates-cvs] cvs commit: TT3/t/tagset tt.t

cvs@template-toolkit.org cvs@template-toolkit.org
Wed, 10 Nov 2004 18:46:35 +0000


cvs         04/11/10 18:46:35

  Modified:    t/tagset tt.t
  Log:
  * added tests for specifying additional 'tags' as a config option
  
  Revision  Changes    Path
  1.2       +41 -17    TT3/t/tagset/tt.t
  
  Index: tt.t
  ===================================================================
  RCS file: /template-toolkit/TT3/t/tagset/tt.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tt.t	2004/11/10 18:22:27	1.1
  +++ tt.t	2004/11/10 18:46:35	1.2
  @@ -9,7 +9,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: tt.t,v 1.1 2004/11/10 18:22:27 abw Exp $
  +# $Id: tt.t,v 1.2 2004/11/10 18:46:35 abw Exp $
   #
   #========================================================================
   
  @@ -31,22 +31,6 @@
   my $pkg = 'Template::Tagset::TT';
   my $regex;
   
  -# define some alternate tags
  -my $start = {
  -    foo => '<foo:',
  -    bar => '<bar:',
  -    bam => qr/(?i:<bam:)/,
  -    baz => '<baz:',
  -};
  -my $end = {
  -    foo => '>',
  -};
  -
  -my $footag  = {
  -    start => $start->{ foo },
  -    end   => $end->{ foo },
  -};
  -
   my $tagset = $pkg->new() || die $pkg->error();
   ok( $tagset, 'created a TT tagset' );
   ok( $tagset->tag('directive'), 'got directive tag' );
  @@ -201,3 +185,43 @@
   ok( $tagset->directive->disabled(), 'tag is disabled' );
   ok( $regex = $tagset->regex(), 'no tagset regex' );
   ok( ("hello [% world" =~ $regex) ? 0 : 1, 'did not match any tags [%' );
  +
  +
  +#------------------------------------------------------------------------
  +# test additional tags passed as constructor params
  +#------------------------------------------------------------------------
  +
  +# define some alternate tags
  +my $start = {
  +    foo => '<foo:',
  +    bar => '<bar:',
  +    bam => qr/(?i:<bam:)/,
  +    baz => '<baz:',
  +};
  +my $end = {
  +    foo => '>',
  +    bar => '>',
  +};
  +
  +my $tagpkg = 'Template::Tag';
  +my $footag = $tagpkg->new({
  +    start => $start->{ foo },
  +    end   => $end->{ foo },
  +});
  +my $bartag = $tagpkg->new({
  +    start => $start->{ bar },
  +    end   => $end->{ bar },
  +});
  +
  +$tagset = $pkg->new( tags => [ foo => $footag, bar => $bartag ] )
  +    || die $pkg->error();
  +
  +ok( $tagset, 'created a tagset with custom tags' );
  +is( $tagset->tag('directive')->start(), '[%', 'directive start' );
  +is( $tagset->tag->{ foo }->start(), '<foo:', 'foo start' );
  +is( $tagset->tag->{ bar }->start(), '<bar:', 'bar start' );
  +
  +
  +#------------------------------------------------------------------------
  +# test subclass
  +#------------------------------------------------------------------------