[Templates-cvs] cvs commit: TT3/t/parser term.t

cvs@template-toolkit.org cvs@template-toolkit.org
Thu, 02 Dec 2004 16:46:47 +0000


cvs         04/12/02 16:46:47

  Modified:    t/parser term.t
  Log:
  * added some more tests for terms
  
  Revision  Changes    Path
  1.13      +103 -8    TT3/t/parser/term.t
  
  Index: term.t
  ===================================================================
  RCS file: /template-toolkit/TT3/t/parser/term.t,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- term.t	2004/12/01 17:57:54	1.12
  +++ term.t	2004/12/02 16:46:47	1.13
  @@ -10,7 +10,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: term.t,v 1.12 2004/12/01 17:57:54 abw Exp $
  +# $Id: term.t,v 1.13 2004/12/02 16:46:47 abw Exp $
   #
   #========================================================================
   
  @@ -20,7 +20,7 @@
   use lib qw( ./lib ../lib ../../lib );
   use Template::Parser;
   use Template::Generator::Debug;
  -use Template::Test tests => 64, import => ':all';
  +use Template::Test tests => 68, import => ':all';
   
   our $DEBUG = 
   $Template::Parser::DEBUG =
  @@ -138,6 +138,7 @@
   
   
   
  +
   __DATA__
   # term : number | squote | dquote | qwlist | list | hash | paren | var
   # number: sign ( hexnum | float exponent )
  @@ -417,7 +418,32 @@
     <text: baz>
   >
   
  +-- test embedded vars with comments in args --
  +-- block --
  +"foo ${ bar(     # this is also a comment
  +             10  # so is this  
  +           )    
  +       } baz"
  +-- expect --
  +<dquote:
  +  <text:foo >
  +  <variable:
  +    <node:
  +      <ident:bar>
  +      <args:
  +        <number:10>
  +      >
  +    >
  +  >
  +  <text: baz>
  +>
  +
  +-- test trailing text after embedded variable --
  +"foo ${ bar(10) some trailing text } baz"
  +-- expect --
  +<ERROR:unexpected text after embedded variable: some trailing text>
   
  +
   #========================================================================
   # qw list
   #=======================================================================
  @@ -501,8 +527,23 @@
     <qwlist(<, >):one two three four>
   >
   
  +-- test qw[] with lots of whitespace --
  +-- block --
  +qw[
  +
  +  foo
  +
  +  bar
   
  +  baz
   
  +]
  +-- expect --
  +<list:
  +  <qwlist([, ]):foo bar baz>
  +>
  +
  +
   #========================================================================
   # list
   #=======================================================================
  @@ -759,7 +800,8 @@
   
   -- test list with embedded comments --
   -- block --
  -[ 10 # foo
  +[ # a list
  +  10 # foo
     20 # bar
     30 # baz 
   ]
  @@ -770,12 +812,63 @@
     <number:30>
   >
   
  --- test TODO more list with expression --
  -#[ a + 2, b ? c : d, e or f ]
  -#[ a b c or d a + 2 > 3 ? e : f ]
  +-- test list with expressions and commas --
  +[ 2 + 2, 3 ? 4 : 5, 6 or 7 ]
   -- expect --
  -#<list:>
  +<list:
  +  <binary:
  +    <number:2>
  +    <op:+>
  +    <number:2>
  +  >
  +  <tertiary:
  +    <expression:
  +      <number:3>
  +    >
  +    <true:
  +      <number:4>
  +    >
  +    <false:
  +      <number:5>
  +    >
  +  >
  +  <binary:
  +    <number:6>
  +    <op:or>
  +    <number:7>
  +  >
  +>
   
  +-- test list with expressions and whitespace --
  +[ 3 + 3 4 or 5 6 > 7 ? 8 : 9 ]
  +-- expect --
  +<list:
  +  <binary:
  +    <number:3>
  +    <op:+>
  +    <number:3>
  +  >
  +  <binary:
  +    <number:4>
  +    <op:or>
  +    <number:5>
  +  >
  +  <tertiary:
  +    <expression:
  +      <binary:
  +        <number:6>
  +        <op:>>
  +        <number:7>
  +      >
  +    >
  +    <true:
  +      <number:8>
  +    >
  +    <false:
  +      <number:9>
  +    >
  +  >
  +>
   
   
   
  @@ -859,6 +952,7 @@
     x => 20 # more comments
     # another comment
     y => 30,
  +  # final comment
   }
   -- expect --
   <hash:
  @@ -952,7 +1046,8 @@
   
   -- test parens comments --
   -- block --
  -(   a   # this is the variable a
  +(       # this is a comment
  +    a   # this is the variable a
           # which holds the first value
       +   # which we are going to add to
       b   # our second variable, b