File: 30_arrays.t

package info (click to toggle)
libhtml-template-compiled-perl 1.003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 772 kB
  • sloc: perl: 4,759; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 818 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use warnings;
use strict;
use lib 't';
use Test::More tests => 5;
use_ok('HTML::Template::Compiled');
use HTC_Utils qw($cache $tdir &cdir);

{
    my $htc = HTML::Template::Compiled->new(
        scalarref => \<<'EOM',
test <%= .array[0][0] %>
Count outer:   <%= .array# %>
Count undef:   <%= .undef# %>
Count inner 1: <%= .array[0]# %>
Count inner 2: <%= .array[1]# %>
EOM
        debug    => 0,
    );

    $htc->param(
        array => [
            [qw(a b c)],
            [qw(d e f g)],
        ],
    );
    my $out = $htc->output;
    #print "out: $out\n";
    cmp_ok($out, '=~', "Count outer: +2", "array count 1");
    cmp_ok($out, '=~', "Count inner 1: +3", "array count 2");
    cmp_ok($out, '=~', "Count inner 2: +4", "array count 3");
    cmp_ok($out, '=~', "Count undef: +0", "undef array count");

}