File: v2_02_property.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 (51 lines) | stat: -rw-r--r-- 1,582 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
#!/usr/bin/perl -T
# 02_property.t

use Test::More tests => 34;
use Paranoid;
use Parse::PlainConfig::Legacy;

use strict;
use warnings;

psecureEnv();

my $conf        = new Parse::PlainConfig::Legacy;
my %properties  = (
    PARAM_DELIM     => '*',
    LIST_DELIM      => ':',
    HASH_DELIM      => '>',
    AUTOPURGE       => 1,
    SMART_PARSER    => 1,
    PADDING         => 3,
    FILE            => 'foo',
    MTIME           => 3,
    );
my ($key, $value, %tmp);

# Test setting bad properties/values
ok( !eval '$conf->property( FOO => "bar" )', 'bad property 1');
ok( !$conf->property( PARAM_DELIM => [] ), 'bad property 2');
ok( !$conf->property( ORDER => "foo" ), 'bad property 3');
ok( !$conf->property( COERCE => [] ), 'bad property 4');
ok( !$conf->property( COERCE => { FOO => 'bar' } ), 'bad property 5');

# Test valid properties
while ( ( $key, $value ) = each %properties ) {
    isnt( $conf->property( $key ), $value, "property $key default value" );
    ok( $conf->property( $key => $value ), "property $key set");
    is( $conf->property( $key ), $value, "property $key value $value");
}
ok( $conf->property( ORDER => [ qw(FOO BAR ROO) ] ), 'property ORDER set');
($key, $value) = @{ $conf->property( 'ORDER' ) };
is( $value, 'BAR', 'property ORDER get');
ok( $conf->property( COERCE => {
    FOO => 'list',
    BAR => 'string',
    ROO => 'hash',
    }), 'property COERCE set');
%tmp = %{ $conf->property( 'COERCE' ) };
is( $tmp{FOO}, 'list', 'property COERCE get');
ok( $conf->property( MAX_BYTES => 512 ), 'property MAX_BYTES set' );

# end 02_property.t