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

cvs@template-toolkit.org cvs@template-toolkit.org
Fri, 03 Dec 2004 13:38:02 +0000


cvs         04/12/03 13:38:02

  Modified:    t/tag    directive.t
  Log:
  * added tests for nested tags
  
  Revision  Changes    Path
  1.15      +305 -1    TT3/t/tag/directive.t
  
  Index: directive.t
  ===================================================================
  RCS file: /template-toolkit/TT3/t/tag/directive.t,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- directive.t	2004/12/01 18:31:06	1.14
  +++ directive.t	2004/12/03 13:38:01	1.15
  @@ -9,7 +9,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: directive.t,v 1.14 2004/12/01 18:31:06 abw Exp $
  +# $Id: directive.t,v 1.15 2004/12/03 13:38:01 abw Exp $
   #
   #========================================================================
   
  @@ -704,6 +704,310 @@
     >
     <text:\nlast text>
   >
  +
  +
  +
  +#------------------------------------------------------------------------
  +# test nested tags
  +#------------------------------------------------------------------------
  +
  +-- start --
  +
  +-- test nested tag --
  +[% x = [% INCLUDE bar %] %]
  +-- expect --
  +<template:
  +  <line:1>
  +  <set:
  +    <assign:
  +      <variable:
  +        <node:
  +          <ident:x>
  +        >
  +      >
  +      <block:
  +        [
  +          <line:1>
  +          <include:
  +            <path:bar>
  +            <no args>
  +          >
  +        ]
  +      >
  +    >
  +  >
  +>
  +
  +
  +-- test nested tag with different tags --
  +[% TAGS star %]
  +[* y = [* INCLUDE baz *] *]
  +-- expect --
  +<template:
  +  <line:1>
  +  <text:\n>
  +  <line:2>
  +  <set:
  +    <assign:
  +      <variable:
  +        <node:
  +          <ident:y>
  +        >
  +      >
  +      <block:
  +        [
  +          <line:2>
  +          <include:
  +            <path:baz>
  +            <no args>
  +          >
  +        ]
  +      >
  +    >
  +  >
  +>
  +
  +-- test nested tag with chomping flags--
  +[% z = [%- INCLUDE bam -%] %]
  +-- expect --
  +<template:
  +  <line:1>
  +  <set:
  +    <assign:
  +      <variable:
  +        <node:
  +          <ident:z>
  +        >
  +      >
  +      <block:
  +        [
  +          <line:1>
  +          <include:
  +            <path:bam>
  +            <no args>
  +          >
  +        ]
  +      >
  +    >
  +  >
  +>
  +
  +
  +-- test nested tag with multiple directives --
  +[% x = [% INCLUDE bar; INCLUDE baz; INCLUDE bam %] %]
  +-- expect --
  +<template:
  +  <line:1>
  +  <set:
  +    <assign:
  +      <variable:
  +        <node:
  +          <ident:x>
  +        >
  +      >
  +      <block:
  +        [
  +          <line:1>
  +          <include:
  +            <path:bar>
  +            <no args>
  +          >
  +          <include:
  +            <path:baz>
  +            <no args>
  +          >
  +          <include:
  +            <path:bam>
  +            <no args>
  +          >
  +        ]
  +      >
  +    >
  +  >
  +>
  +
  +-- test nested tag with multiple directives on many lines--
  +[% x = [% 
  +     INCLUDE bar; 
  +     INCLUDE baz; 
  +     INCLUDE bam 
  +   %]
  +%]
  +-- expect --
  +<template:
  +  <line:1>
  +  <set:
  +    <assign:
  +      <variable:
  +        <node:
  +          <ident:x>
  +        >
  +      >
  +      <block:
  +        [
  +          <line:1>
  +          <include:
  +            <path:bar>
  +            <no args>
  +          >
  +          <line:3>
  +          <include:
  +            <path:baz>
  +            <no args>
  +          >
  +          <line:4>
  +          <include:
  +            <path:bam>
  +            <no args>
  +          >
  +        ]
  +      >
  +    >
  +  >
  +>
  +
  +-- test nested tag with complex directive --
  +[% INCLUDE header
  +      author = 'Arthur Dent'
  +      title  = [% WRAPPER bold;
  +                    IF x; 
  +                       INCLUDE x/title;
  +                    ELSIF y;
  +                       INCLUDE y/title;
  +                    ELSE;
  +                       INCLUDE z/title;
  +                    END;
  +                  END
  +                %]
  +      size = 10;
  +
  +    20; 
  +    30;
  +%]
  +-- expect --
  +<template:
  +  <line:1>
  +  <include:
  +    <path:header>
  +    <args:
  +      <tuple:
  +        <ident:author>
  +        <squote:Arthur Dent>
  +      >
  +      <tuple:
  +        <ident:title>
  +        <block:
  +          [
  +            <line:3>
  +            <wrapper:
  +              <path:bold>
  +              <no args>
  +              <block:
  +                <line:4>
  +                <if:
  +                  <variable:
  +                    <node:
  +                      <ident:x>
  +                    >
  +                  >
  +                  <block:
  +                    <line:5>
  +                    <include:
  +                      <path:x/title>
  +                      <no args>
  +                    >
  +                    <line:6>
  +                  >
  +                  <block:
  +                    <if:
  +                      <variable:
  +                        <node:
  +                          <ident:y>
  +                        >
  +                      >
  +                      <block:
  +                        <line:7>
  +                        <include:
  +                          <path:y/title>
  +                          <no args>
  +                        >
  +                        <line:8>
  +                      >
  +                      <block:
  +                        <line:9>
  +                        <include:
  +                          <path:z/title>
  +                          <no args>
  +                        >
  +                        <line:10>
  +                      >
  +                    >
  +                  >
  +                >
  +                <line:11>
  +              >
  +            >
  +          ]
  +        >
  +      >
  +      <tuple:
  +        <ident:size>
  +        <number:10>
  +      >
  +    >
  +  >
  +  <line:15>
  +  <get:
  +    <number:20>
  +  >
  +  <line:16>
  +  <get:
  +    <number:30>
  +  >
  +  <line:17>
  +>
  +
  +-- test nested directives within nested directives --
  +[% INCLUDE foo
  +     bar = [% INCLUDE baz
  +                wam = [% INCLUDE bam %]
  +           %]
  +%]
  +-- expect --
  +<template:
  +  <line:1>
  +  <include:
  +    <path:foo>
  +    <args:
  +      <tuple:
  +        <ident:bar>
  +        <block:
  +          [
  +            <line:2>
  +            <include:
  +              <path:baz>
  +              <args:
  +                <tuple:
  +                  <ident:wam>
  +                  <block:
  +                    [
  +                      <line:3>
  +                      <include:
  +                        <path:bam>
  +                        <no args>
  +                      >
  +                    ]
  +                  >
  +                >
  +              >
  +            >
  +          ]
  +        >
  +      >
  +    >
  +  >
  +>
  +
   
   -- stop --