[Templates-cvs] cvs commit: Template2/t vars.t
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 07/02/09 16:50:58
Modified: t vars.t
Log:
added tests of the new expressions-as-arguments features
Revision Changes Path
2.9 +32 -1 Template2/t/vars.t
Index: vars.t
===================================================================
RCS file: /template-toolkit/Template2/t/vars.t,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -r2.8 -r2.9
--- vars.t 2006/05/26 13:46:27 2.8
+++ vars.t 2007/02/09 16:50:58 2.9
@@ -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.8 2006/05/26 13:46:27 abw Exp $
+# $Id: vars.t,v 2.9 2007/02/09 16:50:58 abw Exp $
#
#========================================================================
@@ -85,6 +85,7 @@
'_private' => 123,
'_hidden' => 456,
expose => sub { undef $Template::Stash::PRIVATE },
+ add => sub { $_[0] + $_[1] },
# don't define a 'z' - DEFAULT test relies on its non-existance
};
@@ -588,3 +589,33 @@
[% "x" _ "y" == "xy" # should be ("x"_"y")=="xy", not "x"_("y"=="xy") %]
-- expect --
1
+
+-- test --
+[% add(3, 5) %]
+-- expect --
+8
+
+-- test --
+[% add(3 + 4, 5 + 7) %]
+-- expect --
+19
+
+-- test --
+[% a = 10;
+ b = 20;
+ c = 30;
+ add(add(a,b+1),c*3);
+%]
+-- expect --
+121
+
+-- test --
+[% a = 10;
+ b = 20;
+ c = 30;
+ d = 5;
+ e = 7;
+ add(a+5, b < 10 ? c : d + e*5);
+-%]
+-- expect --
+55