I've been trying to use Template::Plugin::Assert without success - perhaps I am just misunderstading something fundamental. Here is my trivial test script.
use strict;
use warnings;
use Template;
use Test::More tests => 1;
my $template = Template->new ();
my $v = { foo => { bar => 999 } };
my $tsrc = <<EOT;
[% USE assert %]
[% foo.assert.bar %]
EOT
ok $template->process (\$tsrc, $v), 'Assert passes' or
diag $template->error ();
I expect this to pass but it fails with assert error - undefined value for bar.
It appears that the test script shipped with the dist only tests for the cases when assert should throw. It never tests the case when assert should pass.
I've been trying to use Template::Plugin::Assert without success - perhaps I am just misunderstading something fundamental. Here is my trivial test script.
I expect this to pass but it fails with
assert error - undefined value for bar
.It appears that the test script shipped with the dist only tests for the cases when assert should throw. It never tests the case when assert should pass.
What am I missing here?
Tested on perl 5.34.0, Template version 3.010.