File: 02random.t

package info (click to toggle)
libhtml-template-pro-perl 0.9524-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,512 kB
  • sloc: ansic: 1,841; perl: 1,474; yacc: 404; pascal: 118; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use Test::More tests => 200;
use HTML::Template::Pro;

use strict;

my $text = q{<TMPL_IF foo>YES<TMPL_ELSE>NO</TMPL_IF>};

my $template = HTML::Template->new(
	scalarref => \$text,
);
$template->param(foo => sub { int(rand(2)) });

# make sure HTML::Template never goes both ways down an if, which it
# used to do because it would re-evaluate the conditional at the else.
# Need to test it many times to be sure since it can guess right.
my $good = 1;
for (1..200) {
    my $r = $template->output;
    ok($r eq 'YES' or $r eq 'NO');
};