forked from bestpractical/template-declare
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Its make exceptional situations fatal. False by default, but consider changing in the future.
- Loading branch information
Showing
4 changed files
with
80 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use warnings; | ||
use strict; | ||
|
||
package Wifty::UI; | ||
use base qw/Template::Declare/; | ||
use Template::Declare::Tags; | ||
|
||
template oops => sub { | ||
with( id => 'foo', id => 'foo' ), html { | ||
}; | ||
}; | ||
|
||
package main; | ||
|
||
use Test::More tests => 11; | ||
use Test::Warn; | ||
|
||
############################################################################## | ||
Template::Declare->init(dispatch_to => ['Wifty::UI']); | ||
pass 'Init with no strict setting'; | ||
|
||
warning_like { Template::Declare->show('nonesuch' ) } | ||
qr/The template 'nonesuch' could not be found [(]it might be private[)]/, | ||
'Should get warning for nonexistent template'; | ||
|
||
warning_like { Template::Declare->show('oops' ) } | ||
qr/HTML appears to contain illegal duplicate element id: foo/, | ||
'Should get warning for duplicate "id" attribute'; | ||
|
||
############################################################################## | ||
Template::Declare->init(dispatch_to => ['Wifty::UI'], strict => 0); | ||
pass 'Init with strict off'; | ||
|
||
warning_like { Template::Declare->show('nonesuch' ) } | ||
qr/The template 'nonesuch' could not be found [(]it might be private[)]/, | ||
'Should still get warning for nonexistent template'; | ||
|
||
warning_like { Template::Declare->show('oops' ) } | ||
qr/HTML appears to contain illegal duplicate element id: foo/, | ||
'Should still get warning for duplicate "id" attribute'; | ||
|
||
############################################################################## | ||
Template::Declare->init(dispatch_to => ['Wifty::UI'], strict => 1); | ||
pass 'Init with strict on'; | ||
|
||
undef $@; | ||
eval { Template::Declare->show('nonesuch' ) }; | ||
ok my $err = $@, 'Should get exception for missing template'; | ||
like $err, | ||
qr/The template 'nonesuch' could not be found [(]it might be private[)]/, | ||
'... and it should be about nonexistent template'; | ||
|
||
undef $@; | ||
eval { Template::Declare->show('oops' ) }; | ||
ok my $err = $@, 'Should get exception for duplicate "id"'; | ||
like $err, | ||
qr/HTML appears to contain illegal duplicate element id: foo/, | ||
'... and it should be about the duplicate "id" attribute'; |