File: 08.constructor.t

package info (click to toggle)
libconfig-tiny-perl 2.30-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 208 kB
  • sloc: perl: 394; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use Config::Tiny;

use Test::More tests => 4;

# ------------------------

my($conf1) = Config::Tiny -> new( { _=>{foo=>"bar"} } );
my($str1)  = $conf1->write_string;
is $str1, "foo=bar\n";

my($conf2) = Config::Tiny -> new( { _=>{hello=>"world"}, Cool=>{Beans=>"Dude",someval=>123} } );
my($str2)  = $conf2->write_string;
is $str2, <<'EOF';
hello=world

[Cool]
Beans=Dude
someval=123
EOF

my($conf3) = Config::Tiny -> new( { one => { alpha=>"aaa", beta=>"bbb" },
	two => { abc => 123, def => 456, ghi => 789 } } );
my($str3)  = $conf3->write_string;
is $str3, <<'EOF';
[one]
alpha=aaa
beta=bbb

[two]
abc=123
def=456
ghi=789
EOF

# from synopsis:
my $config = Config::Tiny->new({
	_ => { rootproperty => "Bar" },
	section => { one => "value", Foo => 42 } });
is $config->write_string, <<'EOF';
rootproperty=Bar

[section]
Foo=42
one=value
EOF