Permalink
Browse files

*** empty log message ***

git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@8 d5a88997-0a34-4036-9ed2-92fb5d660d91
  • Loading branch information...
1 parent b4f721c commit 1303d12177dabb021bbb02e17ef1ec22b50cbda6 @abw committed Jul 4, 2000
Showing with 134 additions and 87 deletions.
  1. +36 −16 t/README
  2. +2 −2 t/binop.t
  3. +1 −1 t/include.t
  4. +7 −1 t/list.t
  5. +54 −11 t/output.t
  6. +2 −2 t/parser.t
  7. +9 −10 t/provider.t
  8. +0 −36 t/service2.t
  9. +1 −1 t/stop.t
  10. +12 −1 t/tags.t
  11. +2 −0 t/test/lib/README
  12. +1 −0 t/test/src/README
  13. +1 −0 t/test/src/baz
  14. +2 −0 t/test/src/complex
  15. +1 −0 t/test/src/foobar
  16. +2 −0 t/test/src/golf
  17. +0 −5 t/test/src/tryme
  18. +1 −1 t/try.t
View
@@ -1,25 +1,45 @@
-base.t Test the Template::Base.pm module.
-binop.t Test binary operators
-block.t Test BLOCK definition
+Script Testing...
+-----------------------------------------------------------------------------
+base.t Template::Base.pm module
+binop.t Binary operators
+block.t BLOCK definition
capture.t Capture directive output and assign to a variable
cgi.t Test the CGI script
compile1.t Compile templates to Perl code and save to file
compile2.t Reload above compiled templates without re-parsing
-compile3.t Test that touching source template causes re-compilation
-config.t Test the Template::Config factory module
-context.t Test the Template::Context module
-datafile.t Test the Datafile plugin (Template::Plugin::Datafile)
-document.t Test the Template::Document module
-evalperl.t Test the evaluation of PERL and RAWPERL blocks
-except.t Test the Template::Exception module
-filter.t Test the FILTER directive and various filters
-foreach.t Test the FOREACH directive
-format.t Test the Format plugin (Template::Plugin::Format)
-include.t Test the INCLUDE directive
-iterator.t
+compile3.t Ensure that touching source template causes re-compilation
+config.t Template::Config factory module
+context.t Template::Context module
+datafile.t Datafile plugin (Template::Plugin::Datafile)
+document.t Template::Document module
+evalperl.t Evaluation of PERL and RAWPERL blocks
+exception.t Template::Exception module
+filter.t FILTER directive and various filters
+foreach.t FOREACH directive
+format.t Format plugin (Template::Plugin::Format)
+include.t INCLUDE and PROCESS directive
+iterator.t Template::Iterator and Iterator plugin modules
+list.t List definition and access via various methods
+object.t Binding objects to template variables
+output.t OUTPUT_PATH and OUTPUT options
+provider.t Template::Provider module
+stop.t STOP directive and throwing 'stop' exception
+table.t Table plugin (Template::Plugin::Table)
+tags.t TAGS directive
+url.t URL plugin (Template::Plugin::URL)
+vars.t Variable usage and GET / SET / CALL / DEFAULT directives
+varsv1.t As above, using version 1 handling of leading '$'
+
TODO:
-plugins.t to test PLUGIN_BASE, etc.
+if.t IF / UNLESS / ELSEIF / ELSE directives
+parser.t Template::Parser module
+service.t Template::Service module
+switch.t SWITCH / CASE directives
+plugins.t Template::Plugins provider module
+template.t Template module
+try.t TRY / THROW / CATCH / FINAL directives
+
NOTE: this is an older list. Bit of a mess, don't trust anything here.
View
@@ -20,11 +20,11 @@
use strict;
use lib qw( ../lib );
use Template::Test;
-#use Template::Parser;
+use Template::Parser;
$^W = 1;
$Template::Test::DEBUG = 0;
-#$Template::Parser::DEBUG = 1;
+$Template::Parser::DEBUG = 0;
my $counter = 0;
my $params = {
View
@@ -2,7 +2,7 @@
#
# t/include.t
#
-# Template script testing the INCLUDE directive.
+# Template script testing the INCLUDE and PROCESS directives.
#
# Written by Andy Wardley <abw@cre.canon.co.uk>
#
View
@@ -25,7 +25,6 @@ $^W = 1;
use Template::Parser;
$Template::Test::DEBUG = 0;
-$Template::Parser::DEBUG = 0;
# sample data
my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m,
@@ -121,3 +120,10 @@ Thu
Fri
Sat
Sun
+
+-- test --
+[% data = [ 'one', 'two', data.first ] -%]
+[% data.join(', ') %]
+-- expect --
+one, two, romeo
+
View
@@ -18,22 +18,65 @@
use strict;
use lib qw( ./lib ../lib );
-use vars qw( $DEBUG );
use Template::Test;
+ntests(8);
-ntests(37);
-$DEBUG = 1;
-$Template::Config::DEBUG = 1;
+my $dir = -d 't' ? 't/test' : 'test';
+my $f1 = 'foo.bar';
+my $f2 = 'foo.baz';
+my $file1 = "$dir/tmp/$f1";
+my $file2 = "$dir/tmp/$f2";
-my $factory = 'Template::Config';
+#------------------------------------------------------------------------
my $tt = Template->new({
- INCLUDE_PATH => 'test/src:test/lib',
- PRE_PROCESS => 'config',
- POST_PROCESS => 'footer',
- OUTPUT_PATH => '/tmp',
+ INCLUDE_PATH => "$dir/src:$dir/lib",
+ OUTPUT_PATH => "$dir/tmp",
}) || die Template->error();
-$tt->process('tryme', &callsign)
- || print STDERR $tt->error, "\n";
+unlink($file1) if -f $file1;
+
+ok( $tt->process('foo', &callsign, $f1) );
+ok( -f $file1 );
+
+open(FP, $file1) || die "$file1: $!\n";
+local $/ = undef;
+my $out = <FP>;
+close(FP);
+
+ok( 1 );
+
+ok( $out eq "This is the foo file, a is alpha\n" );
+
+unlink($file1);
+
+#------------------------------------------------------------------------
+
+$tt = Template->new({
+ INCLUDE_PATH => "$dir/src:$dir/lib",
+ OUTPUT_PATH => "$dir/tmp",
+ OUTPUT => $f2,
+}) || die Template->error();
+
+unlink($file2) if -f $file2;
+
+ok( $tt->process('foo', &callsign) );
+ok( -f $file2 );
+
+open(FP, $file2) || die "$file2: $!\n";
+local $/ = undef;
+$out = <FP>;
+close(FP);
+
+ok( 1 );
+
+ok( $out eq "This is the foo file, a is alpha\n" );
+
+unlink($file2);
+
+
+
+
+
+
View
@@ -21,8 +21,8 @@ use lib qw( . ../lib );
use Template::Test;
$^W = 1;
-$Template::Test::DEBUG = 0;
-$Template::Parser::DEBUG = 1;
+#$Template::Test::DEBUG = 0;
+#$Template::Parser::DEBUG = 0;
my $config = {
INTERPOLATE => 0,
View
@@ -25,10 +25,9 @@ use Cwd 'abs_path';
$^W = 1;
$Template::Test::DEBUG = 0;
-$Template::Provider::DEBUG = 0;
+#$Template::Provider::DEBUG = 0;
my $DEBUG = 0;
-
my $factory = 'Template::Config';
# script may be being run in distribution root or 't' directory
@@ -151,7 +150,7 @@ __DATA__
Error: [% error.type %] - [% error.info.split(': ').1 %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - not found
-- test --
@@ -162,7 +161,7 @@ Error: file - not found
Error: [% error.type %] - [% error.info.split(': ').1 %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - not found
#------------------------------------------------------------------------
@@ -176,7 +175,7 @@ Error: file - not found
Error: [% error.type %] - [% error.info %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - foo: not found
-- test --
@@ -187,7 +186,7 @@ Error: file - foo: not found
Error: [% error.type %] - [% error.info.split(': ').1 %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - not found
#------------------------------------------------------------------------
@@ -201,7 +200,7 @@ Error: file - not found
Error: [% error.type %] - [% error.info %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - foo: not found
-- test --
@@ -212,7 +211,7 @@ Error: file - foo: not found
Error: [% error.type %] - [% error.info.split(': ').1 %]
[% END %]
-- expect --
-This is the foo file
+This is the foo file, a is
Error: file - not found
@@ -222,13 +221,13 @@ Error: file - not found
-- test --
-- use ttinc --
-[% INCLUDE bar %]
+[% INCLUDE foobar %]
-- expect --
This is the old content
-- test --
[% CALL fixfile('This is the new content') %]
-[% INCLUDE bar %]
+[% INCLUDE foobar %]
-- expect --
This is the new content
View
@@ -1,36 +0,0 @@
-#============================================================= -*-perl-*-
-#
-# t/service.t
-#
-# Test the Template::Service module.
-#
-# Written by Andy Wardley <abw@kfs.org>
-#
-# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
-# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
-#
-# 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::Service;
-
-#$Template::Service::DEBUG = 1;
-
-my $service = Template::Service->new({
- INCLUDE_PATH => 'test/src:test/lib',
- PRE_PROCESS => 'config',
- POST_PROCESS => 'footer',
-});
-
-$service->_dump();
-$service->context->_dump();
-
-print $service->process('tryme', { r => 'romeo' })
- || $service->error();
-
View
@@ -115,7 +115,7 @@ trying
#------------------------------------------------------------------------
-# endure PRE_PROCESS and POST_PROCESS templates get added with STOP
+# ensure PRE_PROCESS and POST_PROCESS templates get added with STOP
#------------------------------------------------------------------------
-- test --
View
@@ -83,6 +83,17 @@ alpha
(+ c +)
-- test --
+# same as 'default'
+[% TAGS template -%]
+[% a %]
+%% b %%
+(+ c +)
+-- expect --
+alpha
+%% b %%
+(+ c +)
+
+-- test --
[% TAGS metatext -%]
[% a %]
%% b %%
@@ -93,7 +104,7 @@ bravo
<* c *>
-- test --
-[% TAGS ttmeta -%]
+[% TAGS template1 -%]
[% a %]
%% b %%
(+ c +)
View
@@ -0,0 +1,2 @@
+This directory contains various template components as used by the
+test scripts.
View
@@ -0,0 +1 @@
+This directory contains template file used by the test scripts.
View
@@ -0,0 +1 @@
+This is the baz file, a: [% a %][% a = 'charlie' %]
View
@@ -22,3 +22,5 @@ This is the footer, author: [% template.author %], version: [% template.version
+
+
View
@@ -0,0 +1 @@
+This is the new content
View
@@ -0,0 +1,2 @@
+[% DEFAULT g = c.f.g -%]
+This is the golf file, g is $g
View
@@ -1,5 +0,0 @@
-This is the src/tryme file
-[%# INCLUDE demo %]
-romeo is: [% r %]
-[%# THROW barf.ola 'been sick' %]
-end of src/tryme
View
@@ -22,7 +22,7 @@ use Template::Test;
$^W = 1;
$Template::Test::DEBUG = 0;
-$Template::Parser::DEBUG = 1;
+#$Template::Parser::DEBUG = 0;
my $ttcfg = {
INCLUDE_PATH => [ qw( t/test/lib test/lib ) ],

0 comments on commit 1303d12

Please sign in to comment.