[Templates-cvs] cvs commit: Template2/t compile3.t
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/05/29 14:31:52
Modified: t compile3.t
Log:
* Added near_line() to be a little bit flexible about what line number
is reported. It appears to change from one version of Perl to another.
Revision Changes Path
2.7 +22 -7 Template2/t/compile3.t
Index: compile3.t
===================================================================
RCS file: /template-toolkit/Template2/t/compile3.t,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- compile3.t 2003/12/02 13:14:30 2.6
+++ compile3.t 2006/05/29 14:31:52 2.7
@@ -13,7 +13,7 @@
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
-# $Id: compile3.t,v 2.6 2003/12/02 13:14:30 abw Exp $
+# $Id: compile3.t,v 2.7 2006/05/29 14:31:52 abw Exp $
#
#========================================================================
@@ -71,7 +71,25 @@
# define 'bust_it' to append a lone "[% TRY %]" onto the end of the
# source file to cause re-compilation to fail
my $replace = {
- bust_it => sub { append_file('[% TRY %]') },
+ bust_it => sub { append_file('[% TRY %]') },
+ near_line => sub {
+ my ($warning, $n) = @_;
+ if ($warning =~ s/line (\d+)/line ${n}ish/) {
+ my $diff = abs($1 - $n);
+ if ($diff < 4) {
+ # That's close enough for rock'n'roll. The line
+ # number reported appears to vary from one version of
+ # Perl to another
+ return $warning;
+ }
+ else {
+ return $warning . " (where 'ish' means $diff!)";
+ }
+ }
+ else {
+ return "no idea what line number that is\n";
+ }
+ }
};
test_expect(\*DATA, $ttcfg, $replace );
@@ -106,9 +124,6 @@
-- test --
[%# we want to break 'compile' to check that errors get reported -%]
[% CALL bust_it -%]
-[% TRY; INCLUDE complex; CATCH; "$error"; END %]
+[% TRY; INCLUDE complex; CATCH; near_line("$error", 18); END %]
-- expect --
-file error - parse error - complex line 18: unexpected end of input
-
-
-
+file error - parse error - complex line 18ish: unexpected end of input