File: 07__hash.t

package info (click to toggle)
libpetal-utils-perl 0.06-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 384 kB
  • sloc: perl: 935; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl

##
## Tests for Petal::Utils :hash modifiers
##

use strict;
#use warnings;

use Test::More qw( no_plan );

use Carp;
use t::LoadPetal;

use Petal::Utils qw( :hash );

my $hash = {
	keys_hash_ref => {
		kkey1 => 'kvalue1',
		kkey2 => 'kvalue2',
		kkey3 => 'kvalue3',
	},
	each_hash_ref => {
		ekey1 => 'evalue1',
		ekey2 => 'evalue2',
		ekey3 => 'evalue3',
	},
};
my $template = Petal->new('hash.html');
my $out      = $template->process( $hash );

# Each
like($out, qr/ekey1 => evalue1/, 'each');
like($out, qr/ekey2 => evalue2/, 'each');
like($out, qr/ekey3 => evalue3/, 'each');

# Keys
like($out, qr/kkey1 =>/, 'keys');
like($out, qr/kkey2 =>/, 'keys');
like($out, qr/kkey3 =>/, 'keys');

# use keys to lookup values
TODO: {
    local $TODO = 'Petal cannot use dynamic hash keys to look up values';
    like($out, qr/kkey1 => kvalue1/, 'dkeys');
}