CC: | abw [...] wardley.org,markdclements [...] yahoo.co.uk |
Subject: | causes silent failure in Template toolkit |
I have been seeing strange behaviour when using Test::MockObject and
Template Toolkit, although I haven't been mocking TT objects. I've
tracked the issue down to an interaction between UNIVERSAL::can and TT.
In summary, TT does not produce any output with the following test case
(although it does under UNIVERSAL::can 1.00):
X:\work\justice\migration>cat template.t
use strict;
use warnings;
use Template;
use UNIVERSAL::can;
use constant TEMPLATEFILE => q(template.tt);
my $template = Template->new( );
$template->process( TEMPLATEFILE , {} ) or die $template->error;
X:\work\justice\migration>perl template.t
(and then having commented out "use UNIVERSAL::can".
X:\work\justice\migration>perl template.t
this is output
X:\work\justice\migration>cat template.tt
this is output
X:\work\justice\migration>
Parts of TT can be trivially fixed to work under UNIVERSAL::can, but, to
quote Andy Wardley (cc'ed, co-author of TT):
The UNIVERSAL::can() call is used in many places in TT and in some of
those places it absolutely has to work as advertised in the Perl core
and not in any other way
Further discussion can be seen at:
http://rt.cpan.org/Ticket/Display.html?id=17503
It would be very useful (to me, at least) if Test::MockObject and TT
could be made to work together.
regards,
Mark