[Jifty-commit] r3064 - Template-Declare/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Mar 26 22:40:29 EDT 2007
Author: ruz
Date: Mon Mar 26 22:40:29 2007
New Revision: 3064
Added:
Template-Declare/t/attributes.t
Log:
* tests for attributes
Added: Template-Declare/t/attributes.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/attributes.t Mon Mar 26 22:40:29 2007
@@ -0,0 +1,91 @@
+
+use warnings;
+use strict;
+
+
+package Wifty::UI;
+use base qw/Template::Declare/;
+use Template::Declare::Tags;
+
+# call to attr with emplecit ';'
+template attr_with_one_arg => sub {
+ div { attr { id => 'id' };
+ p { 'This is my content' }
+ }
+};
+
+template attr_with_two_args => sub {
+ div { attr { id => 'id' }
+ p { 'This is my content' }
+ }
+};
+
+template attr_with_many_args => sub {
+ div { attr { id => 'id' }
+ p { 'This is my content' }
+ p { 'another paragraph' }
+ p { 'another paragraph' }
+ p { 'another paragraph' }
+ }
+};
+
+template with => sub {
+ with( id => 'id' ),
+ div { p { 'This is my content' } }
+};
+
+template with_with_two_blocks => sub {
+ with( id => 'id' ),
+ div { p { 'This is my content' } }
+ div { p { 'another paragraph' } }
+};
+
+Template::Declare->init(roots => ['Wifty::UI']);
+
+1;
+
+use Test::More tests => 10;
+require "t/utils.pl";
+{
+ my $simple = (show('attr_with_one_arg'));
+ ok($simple =~ m{^\s*<div\s+id="id">\s*<p>\s*This is my content\s*</p>\s*</div>\s*$}s);
+ #diag ($simple);
+ ok_lint($simple);
+}
+
+{
+ my $simple = (show('attr_with_two_args'));
+ ok($simple =~ m{^\s*<div\s+id="id">\s*<p>\s*This is my content\s*</p>\s*</div>\s*$}s);
+ #diag ($simple);
+ ok_lint($simple);
+}
+
+{
+ my $simple = (show('attr_with_many_args'));
+ ok($simple =~ m{^\s*
+ <div\s+id="id">\s*
+ <p>\s*This\sis\smy\scontent\s*</p>\s*
+ (<p>\s*another\sparagraph\s*</p>\s*)+
+ </div>\s*
+ $}sx);
+ #diag ($simple);
+ ok_lint($simple);
+}
+
+{
+ my $simple = (show('with'));
+ ok($simple =~ m{^\s*<div\s+id="id">\s*<p>\s*This is my content\s*</p>\s*</div>\s*$}s);
+ #diag ($simple);
+ ok_lint($simple);
+}
+
+{
+ my $simple = (show('with_with_two_blocks'));
+ ok($simple =~ m{^\s*
+ <div\s+id="id">\s*<p>\s*This\sis\smy\scontent\s*</p>\s*</div>
+ <div\s+id="id">\s*<p>\s*Another\sparagraph\s*</p>\s*</div>
+ \s*$}sx);
+ #diag ($simple);
+ ok_lint($simple);
+}
+
More information about the Jifty-commit
mailing list