[Templates-cvs] cvs commit: TT3/t/parser vars.t
cvs@template-toolkit.org
cvs@template-toolkit.org
Mon, 15 Nov 2004 19:17:22 +0000
cvs 04/11/15 19:17:21
Modified: t/parser vars.t
Log:
* updated variable tests
Revision Changes Path
1.3 +23 -10 TT3/t/parser/vars.t
Index: vars.t
===================================================================
RCS file: /template-toolkit/TT3/t/parser/vars.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vars.t 2004/11/10 18:28:27 1.2
+++ vars.t 2004/11/15 19:17:21 1.3
@@ -10,7 +10,7 @@
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
-# $Id: vars.t,v 1.2 2004/11/10 18:28:27 abw Exp $
+# $Id: vars.t,v 1.3 2004/11/15 19:17:21 abw Exp $
#
#========================================================================
@@ -19,7 +19,7 @@
use lib qw( ./lib ../lib ../../lib );
use Template::Parser;
-use Template::TT3::Generator::Debug;
+use Template::Generator::Debug;
use Template::Test qw( :all );
plan(23);
@@ -29,7 +29,7 @@
grep(/^--?d(ebug)?/, @ARGV);
my $ppkg = 'Template::Parser';
-my $gpkg = 'Template::TT3::Generator::Debug';
+my $gpkg = 'Template::Generator::Debug';
my $parser = $ppkg->new()
|| die $ppkg->error();
@@ -41,25 +41,36 @@
test_expect({
handler => \&parse,
- ok => \&ok
});
sub parse {
my $test = shift;
- my @lines = split(/\n/, $test->{ input });
my $result = '';
+ my @lines;
+ # -- block -- flag indicates one single test, otherwise we
+ # split the block into separate lines
+ if ($test->{ inflag }->{ block }) {
+ @lines = $test->{ input };
+ }
+ else {
+ @lines = split(/\n/, $test->{ input });
+ }
+
foreach my $line (@lines) {
- $parser->error(undef);
- my $out = $parser->parse_variable(\$line);
+ my $out = eval {
+ $parser->parse_variable(\$line);
+ };
if ($out) {
$out = $generator->generate($out)
|| die $generator->error();
}
+ elsif ($@) {
+ my $error = ref($@) ? $@->info() : $@;
+ $out = "<ERROR:$error>";
+ }
else {
- $out = defined $out
- ? '<DECLINED>'
- : '<ERROR:' . $parser->error() . '>';
+ $out = '<DECLINED>';
}
$result .= "$out\n";
}
@@ -91,6 +102,7 @@
-- expect --
<ERROR:missing item after '.' (got '&')>
+
-- test foo with arg --
foo(10)
-- expect --
@@ -462,6 +474,7 @@
<ident:length>
>
>
+
-- test list first --
# parse_term() would normally handle this, parse_variable()