File: 03autoviv.t

package info (click to toggle)
libconfig-std-perl 0.903-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: perl: 383; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (8)
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
use Test::More 'no_plan';
use Config::Std;

my $orig_contents = <<EOF;
[section2]

mutating: 0
EOF


my $tmp_file = 'tmp_file';
open my $fh, '>', $tmp_file or die;
print {$fh} $orig_contents;
close $fh;


read_config $tmp_file, my %config;
$config{section2}{mutating}++;
write_config %config;

open $fh, '<', $tmp_file;
my $contents = do {local $/; <$fh>};
close $fh;

ok $contents =~ m/mutating: 1/      =>  'Mutation via hash';

read_config $tmp_file, my $config_ref;
$config_ref->{section2}{mutating}++;
write_config $config_ref;

open $fh, '<', $tmp_file;
$contents = do {local $/; <$fh>};
close $fh;

ok $contents =~ m/mutating: 2/      =>  'Mutation via hash-ref';

unlink $tmp_file;