File: 08-comments.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 (39 lines) | stat: -rw-r--r-- 764 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
# vim: cindent ft=perl sm sw=4

use warnings;
use strict;

use Test::More tests => 3;

BEGIN { use_ok('Config::Scoped') }
my ( $p, $cfg );
isa_ok( $p = Config::Scoped->new(), 'Config::Scoped' );

my $text = <<'eot';
a=b; #comment after parameter assignment
{ # comment in block
    b=c; #again after assignment
    # on an own line
}
hash = { # comment within a hash
    a=b; # after an assignment
    # on an own line
}
#macro foo bar; # after a pragma
#warnings on; #again after a pragma
foo { # in a declaration
    h = { # also here, eats the leading }
        }
}
eot

my $expected = {
    'foo' => {
        'hash' => { 'a' => 'b' },
        'h'    => {},
        'a'    => 'b'
    }
};

is_deeply( $p->parse( text => $text ), $expected, 'comment tests' );