File: 10-lists.t

package info (click to toggle)
libconfig-scoped-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 752 kB
  • ctags: 73
  • sloc: perl: 10,347; makefile: 42
file content (54 lines) | stat: -rw-r--r-- 958 bytes parent folder | download | duplicates (6)
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
# vim: cindent ft=perl sm sw=4

use warnings;
use strict;

use Test::More tests => 4;

BEGIN { use_ok('Config::Scoped') }
my ( $p, $cfg );

my $text = <<'eot';
list = [ #comment
    1 2 3, 4 5,  # comment 7 8 9 0 ]
    #############
    6, '7', "8",
    # # # # #
    9
    10
#############]
]
eot

my $expected =
  { '_GLOBAL' =>
      { 'list' => [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ] } };


isa_ok( $p = Config::Scoped->new(), 'Config::Scoped' );
is_deeply( $p->parse( text => $text ), $expected, 'list test, comments' );


$text = <<'eot';
list = [ #comment
    [ 1 2 ], {a=b, c = [ d e ]}, foo, bar 
# comment
]
eot

$expected = {
    '_GLOBAL' => {
        'list' => [
            [ '1', '2' ],
            {
                'c' => [ 'd', 'e' ],
                'a' => 'b'
            },
            'foo', 'bar'
        ]
    }
};

$p = Config::Scoped->new();
is_deeply( $p->parse( text => $text ), $expected, 'list test, complex' );