[Templates-cvs] cvs commit: Template2/t vars.t

cvs@template-toolkit.org cvs@template-toolkit.org


cvs         06/05/14 07:05:14

  Modified:    t        vars.t
  Log:
  * added tests for private/hidden variables
  
  Revision  Changes    Path
  2.7       +17 -4     Template2/t/vars.t
  
  Index: vars.t
  ===================================================================
  RCS file: /template-toolkit/Template2/t/vars.t,v
  retrieving revision 2.6
  retrieving revision 2.7
  diff -u -r2.6 -r2.7
  --- vars.t	2002/01/21 10:30:38	2.6
  +++ vars.t	2006/05/14 07:05:14	2.7
  @@ -12,7 +12,7 @@
   # This is free software; you can redistribute it and/or modify it
   # under the same terms as Perl itself.
   #
  -# $Id: vars.t,v 2.6 2002/01/21 10:30:38 abw Exp $
  +# $Id: vars.t,v 2.7 2006/05/14 07:05:14 abw Exp $
   #
   #========================================================================
   
  @@ -81,7 +81,9 @@
       'gee'      =>  'g',
       "letter$a" => "'$a'",
       'yankee'   => \&yankee,
  -    _private   => 123,
  +    '_private' => 123,
  +    '_hidden'  => 456,
  +    expose     => sub { undef $Template::Stash::PRIVATE },
   
       # don't define a 'z' - DEFAULT test relies on its non-existance
   };
  @@ -525,10 +527,21 @@
   Gandalf
   Mithrandir, Olorin, Incanus
   
  +
  +# test private variables
   -- test --
  -[[% _private %]]
  +[[% _private %]][[% _hidden %]]
   -- expect --
  -[]
  +[][]
  +
  +# make them visible
  +-- test --
  +[% CALL expose -%]
  +[[% _private %]][[% _hidden %]]
  +-- expect --
  +[123][456]
  +
  +
   
   # Stas reported a problem with spacing in expressions but I can't
   # seem to reproduce it...