File: 6_sorted.t

package info (click to toggle)
libconfig-properties-perl 1.80-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 479; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,181 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use Test::More tests => 8;

use Config::Properties;
use File::Temp qw(tempfile);

my $cfg=Config::Properties->new();
$cfg->load(\*DATA);

my ($fh, $fn)=tempfile()
    or die "unable to create temporal file to save properties";

$cfg->deleteProperty('dos');
$cfg->setProperty('cinco', '5');
$cfg->setProperty('tres', '6!');

$cfg->store($fh, "test header");
ok(close($fh), "config write");
open CFG, '<', $fn
    or die "unable to open tempory file $fn";

undef $/;
$contents=<CFG>;
ok(close(CFG), "config read");

# print STDERR "$fn\n$contents\n";

ok($contents=~/uno.*tres.*cuatro.*cinco/s,
   "order preserved");

unlink $fn;

ok((not -e $fn), "delete test file");

($fh, $fn)=tempfile()
    or die "unable to create temporal file to save properties";

$cfg->order('alpha');

$cfg->store($fh, "test header");
ok(close($fh), "config write");
open CFG, '<', $fn
    or die "unable to open tempory file $fn";

undef $/;
$contents=<CFG>;
ok(close(CFG), "config read");

# print STDERR "$fn\n$contents\n";

ok($contents=~/cinco.*cuatro.*tres.*uno/s,
   "alpha order preserved");

unlink $fn;

ok((not -e $fn), "delete test file");

__DATA__

uno = 1u
dos = 2u
tres = 3u
cuatro = 4u