File: v2_08_hash.t

package info (click to toggle)
libparse-plainconfig-perl 3.07-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 1,916; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download | duplicates (5)
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
48
49
50
51
52
# 08_hash.t
#
# Tests for proper extraction of hash values

use Parse::PlainConfig::Legacy;

$|++;
print "1..6\n";

my $test   = 1;
my $rcfile = './t/v2_testrc';
my $conf   = Parse::PlainConfig::Legacy->new(FILE => $rcfile);
$conf->read($rcfile);
my %hash = ( $conf->parameter("HASH 1") );

# 1 hash 1
$hash{two} eq "2" ? print "ok $test\n" : print "not ok $test\n";
$test++;

# 2 hash 1
$hash{three} eq "Three for Me! 3 => 2" ?  print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# Set tests
#
# 3 new hash 1
$conf->parameter('NEW HASH 1', { 'foo' => 'bar' });
%hash = $conf->parameter('NEW HASH 1');
$hash{foo} eq "bar" ?  print "ok $test\n" : print "not ok $test\n";
$test++;

# 4 new hash 2 with coercion set
$conf->coerce('hash', 'NEW HASH 2');
$conf->parameter('NEW HASH 2', { 'foo' => 'bar' });
%hash = $conf->parameter('NEW HASH 2');
$hash{foo} eq "bar" ?  print "ok $test\n" : print "not ok $test\n";
$test++;

# 5 new hash 2 with string value
$conf->parameter('NEW HASH 2', "bar => foo");
%hash = $conf->parameter('NEW HASH 2');
$hash{bar} eq "foo" ?  print "ok $test\n" : print "not ok $test\n";
$test++;

# 6 new hash 2 with list value
$conf->parameter('NEW HASH 2', [qw(foo bar roo)]);
%hash = $conf->parameter('NEW HASH 2');
$hash{foo} eq "bar" ?  print "ok $test\n" : print "not ok $test\n";
$test++;

# end 08_hash.t