[Templates-cvs] cvs commit: TT3/t tagset.t
cvs@template-toolkit.org
cvs@template-toolkit.org
Wed, 10 Nov 2004 18:23:44 +0000
cvs 04/11/10 18:23:44
Modified: t tagset.t
Log:
* updated tests as Template::Tagset changed
Revision Changes Path
1.6 +36 -19 TT3/t/tagset.t
Index: tagset.t
===================================================================
RCS file: /template-toolkit/TT3/t/tagset.t,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- tagset.t 2004/11/08 18:47:24 1.5
+++ tagset.t 2004/11/10 18:23:44 1.6
@@ -9,7 +9,7 @@
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
-# $Id: tagset.t,v 1.5 2004/11/08 18:47:24 abw Exp $
+# $Id: tagset.t,v 1.6 2004/11/10 18:23:44 abw Exp $
#
#========================================================================
@@ -22,7 +22,7 @@
#use Template::Tagset::TT;
use Template::Test;
-plan(139);
+plan(144);
my $DEBUG =
$Template::Tagset::DEBUG =
@@ -42,10 +42,13 @@
bam => qr/(?i:<bam:)/,
baz => '<baz:',
};
+my $end = {
+ foo => '>',
+};
my $footag = {
start => $start->{ foo },
- end => '>',
+ end => $end->{ foo },
};
my $bartag = {
start => $start->{ bar },
@@ -236,7 +239,8 @@
is( $tagtags->{ baz }, $baztagobj, 'baz tagset baz tag' );
# create tagset specifying tags as single pair
-$tagset = $tagsetpkg->new( baz => $baztagobj ) || die $tagsetpkg->error();
+$tagset = $tagsetpkg->new( tags => { baz => $baztagobj })
+ || die $tagsetpkg->error();
ok( $tagset, 'created a single baz tagset' );
$tagtags = $tagset->tags();
ok( $tagtags, 'got single baz tagset tags' );
@@ -299,26 +303,25 @@
#------------------------------------------------------------------------
# test tags() method handling nested items.
-# note that some define 'tags' explicitly, others provide them
-# implicitly as either a hash ref or list of named tags
#------------------------------------------------------------------------
$tagset = $tagsetpkg->new({
- # explicit 'tags' config item
tags => {
one => $tagsetpkg->new({
- # assume all config items in hash are tags
- foo => $footagobj,
- two => $tagsetpkg->new(
- # same for list of named params (non-hashref)
- bar => $bartagobj,
- tre => $tagsetpkg->new({
+ tags => {
+ foo => $footagobj,
+ two => $tagsetpkg->new(
tags => {
- baz => $baztagobj,
- },
- disabled => 1,
- }),
- ),
+ bar => $bartagobj,
+ tre => $tagsetpkg->new({
+ tags => {
+ baz => $baztagobj,
+ },
+ disabled => 1,
+ }),
+ }
+ ),
+ },
}),
bam => $bamtagobj,
},
@@ -494,9 +497,23 @@
is_expected_regex( $tagset );
-
+#------------------------------------------------------------------------
+# test the creation of nested tags and tagsets
+#------------------------------------------------------------------------
+$tagsetpkg = 'Template::Tagset';
+$tagset = $tagsetpkg->new({
+ tags => {
+ foo => 'Template::Tag',
+ },
+ %$footag,
+});
+ok( $tagset, 'created tagset with foo tag class' );
+ok( $tag = $tagset->tag('foo'), 'got foo tag' );
+is( ref $tag, 'Template::Tag', 'isa Template::Tag' );
+is( $tag->start(), $start->{ foo }, 'foo start token' );
+is( $tag->end(), $end->{ foo }, 'foo end token' );
__END__