abw / Template2

Perl Template Toolkit v2
http://template-toolkit.org/
146 stars 94 forks source link

Assert always throws #300

Open openstrike opened 2 years ago

openstrike commented 2 years ago

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.

What am I missing here?

Tested on perl 5.34.0, Template version 3.010.