[Jifty-commit] r3889 - in Template-Declare: t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Aug 13 22:45:53 EDT 2007


Author: agentz
Date: Mon Aug 13 22:45:53 2007
New Revision: 3889

Added:
   Template-Declare/t/pitfalls.t
Modified:
   Template-Declare/MANIFEST

Log:
TD - added t/pitfalls.t to test TD pitfalls

Modified: Template-Declare/MANIFEST
==============================================================================
--- Template-Declare/MANIFEST	(original)
+++ Template-Declare/MANIFEST	Mon Aug 13 22:45:53 2007
@@ -35,6 +35,7 @@
 t/indexhtml.t
 t/MyTagSet.pm
 t/namespace.t
+t/pitfalls.t
 t/postprocessor.t
 t/private.t
 t/relative-pathing.t

Added: Template-Declare/t/pitfalls.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/pitfalls.t	Mon Aug 13 22:45:53 2007
@@ -0,0 +1,69 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+
+package MyApp::Templates;
+
+use base 'Template::Declare';
+use Template::Declare::Tags 'XUL', 'HTML' => { namespace => 'html' };
+
+template main => sub {
+    xml_decl { 'xml', version => '1.0' }
+    xml_decl { 'xml-stylesheet',  href => "chrome://global/skin/", type => "text/css" }
+};
+
+template foo => sub {
+    html::p {
+        html::a { attr { src => '1.png' } }
+        html::a { attr { src => '2.png' } }
+        html::a { attr { src => '3.png' } }
+    }
+};
+
+eval q{
+    p { a { attr { src => 'cat.gif' } } }
+};
+::ok $@, 'attr in an invalid tag';
+::like $@, qr/Subroutine attr failed: src => 'cat\.gif'
+\t\(Perhaps you're using an unknown tag in the outer container\?\)/, 'attr in an invalid tag';
+
+template inline => sub {
+    html::p { "hello, "; html::em { "world" } }
+};
+
+eval q{
+    groupbox { attr { id => 'a' } }
+    for (1..10) {
+        radio { attr { id => $_ } }
+    }
+};
+::ok $@, 'semicolon required before for stmt';
+::like $@, qr/syntax error at.*near "\) \{"/, 'error expected';
+
+package main;
+Template::Declare->init( roots => ['MyApp::Templates']);
+my $out = Template::Declare->show('main') . "\n";
+isnt $out, <<_EOC_;
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+_EOC_
+
+$out = Template::Declare->show('foo') . "\n";
+is $out, <<_EOC_;
+
+<html:p>
+ <html:a src="1.png"></html:a>
+ <html:a src="2.png"></html:a>
+ <html:a src="3.png"></html:a>
+</html:p>
+_EOC_
+
+$out = Template::Declare->show('inline') . "\n";
+is $out, <<_EOC_, "'hello, ' is missing";
+
+<html:p>
+ <html:em>world</html:em>
+</html:p>
+_EOC_
+


More information about the Jifty-commit mailing list