Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added t/debug.t and fixes some DEBUG issues in stash.t and foreach.t

git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@381 d5a88997-0a34-4036-9ed2-92fb5d660d91
  • Loading branch information...
commit 6173dda0978497569cd86bade686fe3fbc105a46 1 parent 424f570
@abw authored
Showing with 104 additions and 1 deletion.
  1. +101 −0 t/debug.t
  2. +2 −0  t/foreach.t
  3. +1 −1  t/stash.t
View
101 t/debug.t
@@ -0,0 +1,101 @@
+#============================================================= -*-perl-*-
+#
+# t/debug.t
+#
+# Test the Debug plugin module.
+#
+# Written by Andy Wardley <abw@andywardley.com>
+#
+# Copyright (C) 2002 Andy Wardley. All Rights Reserved.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+#
+# $Id$
+#
+#========================================================================
+
+use strict;
+use lib qw( ./lib ../lib );
+use Template::Test qw( :all );
+$^W = 1;
+
+my $DEBUG = grep(/-d/, @ARGV);
+$Template::Parser::DEBUG = $DEBUG;
+$Template::Directive::Pretty = $DEBUG;
+$Template::Test::PRESERVE = 1;
+
+my $dir = -d 't' ? 't/test' : 'test';
+
+my $vars = {
+ foo => 10,
+ bar => 20,
+ baz => {
+ ping => 100,
+ pong => 200,
+ },
+};
+
+my $tt = Template->new( {
+ DEBUG => 0,
+ INCLUDE_PATH => "$dir/src:$dir/lib",
+ DEBUG_FORMAT => "<!-- \$file line \$line : [% \$text %] -->",
+} );
+
+my $ttd = Template->new( {
+ DEBUG => 1,
+ INCLUDE_PATH => "$dir/src:$dir/lib",
+ DEBUG_FORMAT => "<!-- \$file line \$line : [% \$text %] -->",
+} );
+
+test_expect(\*DATA, [ default => $tt, debug => $ttd ], $vars);
+#$tt->process(\*DATA, $vars) || die $tt->error();
+#print $tt->context->_dump();
+
+__DATA__
+-- test --
+Hello World
+foo: [% foo %]
+[% DEBUG on -%]
+Debugging enabled
+foo: [% foo %]
+-- expect --
+Hello World
+foo: 10
+Debugging enabled
+foo: <!-- input text line 5 : [% foo %] -->10
+
+-- test --
+foo: [% foo %]
+[% DEBUG on -%]
+hello [% "$baz.ping/$baz.pong" %] world
+[% DEBUG off %]
+bar: [% bar %]
+-- expect --
+foo: 10
+hello <!-- input text line 3 : [% "$baz.ping/$baz.pong" %] -->100/200 world
+<!-- input text line 4 : [% DEBUG off %] -->
+bar: 20
+
+-- test --
+[% INCLUDE foo a=10 %]
+[% DEBUG on -%]
+[% INCLUDE foo a=20 %]
+[% foo %]
+-- expect --
+This is the foo file, a is 10
+<!-- input text line 3 : [% INCLUDE foo a=20 %] -->This is the foo file, a is 20
+<!-- input text line 4 : [% foo %] -->10
+
+-- test --
+-- use debug --
+foo: [% foo %]
+[% INCLUDE foo a=10 %]
+[% DEBUG off -%]
+foo: [% foo %]
+[% INCLUDE foo a=20 %]
+-- expect --
+foo: <!-- input text line 1 : [% foo %] -->10
+<!-- input text line 2 : [% INCLUDE foo a=10 %] -->This is the foo file, a is <!-- foo line 1 : [% a %] -->10
+<!-- input text line 3 : [% DEBUG off %] -->foo: 10
+This is the foo file, a is <!-- foo line 1 : [% a %] -->20
View
2  t/foreach.t
@@ -91,6 +91,7 @@ my $template = Template->new({
my $ttdebug = Template->new({
DEBUG => 1,
+ DEBUG_FORMAT => '',
});
test_expect(\*DATA, [ default => $template, debug => $ttdebug ], $params);
@@ -599,6 +600,7 @@ last outer
4,1,1
4,2,1
4,4,1
+
-- test --
[%
LAST FOREACH k = [ 1 .. 4];
View
2  t/stash.t
@@ -64,7 +64,7 @@ match( $stash->get('bar.buz'), 100 );
my $ttlist = [
'default' => Template->new(),
- 'warn' => Template->new(DEBUG => 1),
+ 'warn' => Template->new(DEBUG => 1, DEBUG_FORMAT => ''),
];
test_expect(\*DATA, $ttlist, $data);
Please sign in to comment.
Something went wrong with that request. Please try again.