File: 02random.t

package info (click to toggle)
libhtml-template-pro-perl 0.9502-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,584 kB
  • ctags: 860
  • sloc: ansic: 1,814; perl: 1,442; yacc: 410; pascal: 118; makefile: 5
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');
};