[Jifty-commit] r3102 - in Template-Declare: t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Apr 6 10:07:57 EDT 2007
Author: jesse
Date: Fri Apr 6 10:07:35 2007
New Revision: 3102
Added:
Template-Declare/t/duplicate_element_ids.t
Modified:
Template-Declare/ (props changed)
Log:
r54525 at dhcp207: jesse | 2007-04-06 23:07:11 +0900
* duplicate id tests.
Added: Template-Declare/t/duplicate_element_ids.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/duplicate_element_ids.t Fri Apr 6 10:07:35 2007
@@ -0,0 +1,102 @@
+
+use warnings;
+use strict;
+
+package Template::FarAway;
+use base qw/Template::Declare/;
+use Template::Declare::Tags;
+
+template with_no_dup_id => 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 with_dup_id => sub {
+ with( id => 'foo' ), p {'This is my content'};
+ with( id => 'id' ), p {'another paragraph'};
+ show('with_with_two_blocks');
+ with( id => 'foo' ), p {'This is also my content'};
+};
+
+template with_dup_id_in_uppercase => sub {
+ with( ID => 'id' ), p {'another paragraph'};
+ show('with_with_two_blocks');
+};
+
+template with_dup_id2 => sub {
+ show('with_with_two_blocks');
+ show('with_with_two_blocks');
+};
+
+1;
+
+package main;
+use Test::More tests => 8;
+use Test::Warn;
+
+Template::Declare->init(roots => ['Template::FarAway']);
+
+
+
+{
+ warnings_like { Template::Declare->show('with_dup_id') }
+ [ qr/duplicate\b/i, qr/duplicate\b/i ], "Duplicate id should be warned";
+ Template::Declare->buffer->clear;
+}
+
+{
+ warnings_like { Template::Declare->show('with_dup_id2') }
+ [ qr/duplicate\b/i ], "Duplicate id should be warned";
+ Template::Declare->buffer->clear;
+}
+
+{
+ warning_like { Template::Declare->show('with_dup_id_in_uppercase') }
+ qr/duplicate\b/i, "Duplicate id given in different case should be warned";
+
+ Template::Declare->buffer->clear;
+}
+
+{
+ warning_is { Template::Declare->show('with_no_dup_id') } "",
+ "Should not duplicate id warnings if there are none.";
+ Template::Declare->buffer->clear;
+}
+
+use Template::Declare::Tags;
+
+{
+ warnings_like { show('with_dup_id') }
+ [ qr/duplicate\b/i, qr/duplicate\b/i ], "Duplicate id should be warned";
+ Template::Declare->buffer->clear;
+}
+
+{
+ warnings_like { show('with_dup_id2') }
+ [ qr/duplicate\b/i ], "Duplicate id should be warned";
+ Template::Declare->buffer->clear;
+}
+
+{
+ warning_like { show('with_dup_id_in_uppercase') }
+ qr/duplicate\b/i, "Duplicate id given in different case should be warned";
+
+ Template::Declare->buffer->clear;
+}
+
+{
+ warning_is { show('with_no_dup_id') } "",
+ "Should not duplicate id warnings if there are none.";
+ Template::Declare->buffer->clear;
+}
+
More information about the Jifty-commit
mailing list