File: v2_05_purge.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 (42 lines) | stat: -rw-r--r-- 1,040 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
#!/usr/bin/perl -T
# 05_purge.t

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

use strict;
use warnings;

psecureEnv();

my $testrc = "./t/v2_testrc";
my $conf   = Parse::PlainConfig::Legacy->new(FILE => $testrc);
my (@params, $p);

ok( $conf->read, 'read 1' );
@params = $conf->parameters;
ok( scalar @params > 1, 'has parameters 1' );
ok( $conf->purge, 'purge 1');
@params = $conf->parameters;
ok( scalar @params == 0, 'has parameters 2' );

$conf = Parse::PlainConfig::Legacy->new(
    FILE        => $testrc,
    DEFAULTS    => {
        'SCALAR 1'  => 'foo',
        'SCALAR 2'  => 'bar',
        'UNDEC'     => 5,
        },
    );
ok( $conf->read, 'read 2' );
ok( $conf->purge, 'purge 2');
@params = $conf->parameters;
ok( scalar @params > 1, 'has parameters 3' );
($p) = grep /^UNDEC$/, @params;
ok( $p eq 'UNDEC', 'has default parameter' );
is( $conf->parameter( 'UNDEC' ), 5, 'default param value match' );
@params = $conf->parameters;
ok( scalar @params == 3, 'has parameters 4' );

# end 05_purge.t