File: basic.t

package info (click to toggle)
libconfig-mvp-perl 2.101650-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 228 kB
  • ctags: 59
  • sloc: perl: 595; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download
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
#!perl
use strict;
use warnings;
use lib 't/lib';

use Test::More tests => 11;

require_ok( 'Config::MVP::Assembler' );

my $assembler = Config::MVP::Assembler->new;

my $section = Config::MVP::Section->new({
  name => '_',
});

$assembler->sequence->add_section($section);

$assembler->add_value(foo => 10);
$assembler->add_value(bar => 11);

$assembler->change_section('Foo::Bar');
$assembler->add_value(x => 10);
$assembler->add_value(y => 20);
$assembler->add_value(y => 30);
$assembler->add_value(z => -123);

$assembler->change_section('Foo::Bar', 'baz');
$assembler->add_value(x => 1);

$assembler->finalize;

my @sections = $assembler->sequence->sections;

is(@sections, 3, "there are three sections");
is($sections[0]->name, '_');
is($sections[1]->name, 'Foo::Bar');
is($sections[2]->name, 'baz');

is($sections[0]->package, undef);
is($sections[1]->package, 'Foo::Bar');
is($sections[2]->package, 'Foo::Bar');

is_deeply($sections[0]->payload, { bar => 11, foo => 10 });
is_deeply($sections[1]->payload, { x => 10, y => [ 20, 30 ], z => -123 });
is_deeply($sections[2]->payload, { x => 1 });