[go: up one dir, main page]

File: config.t

package info (click to toggle)
rex 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,800 kB
  • sloc: perl: 30,667; xml: 264; makefile: 8
file content (46 lines) | stat: -rw-r--r-- 1,157 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
use strict;
use warnings;

use Test::More tests => 9;

use Rex::Config;

Rex::Config->set( "test", "foobar" );
is( Rex::Config->get("test"), "foobar", "setting scalars" );

Rex::Config->set( "test_a", [qw/one two three/] );
is( Rex::Config->get("test_a")->[1], "two", "setting arrayRef" );
is_deeply(
  Rex::Config->get('test_a'),
  [qw/one two three/], "compare complete arrayRef",
);

Rex::Config->set( "test_a", [qw/four/] );
ok(
  Rex::Config->get("test_a")->[-1] eq "four"
    && Rex::Config->get("test_a")->[0] eq "one",
  "adding more to arrayRef"
);
is_deeply(
  Rex::Config->get('test_a'),
  [qw/one two three four/], "compare complete arrayRef",
);

Rex::Config->set( "test_h", { name => "john" } );
is( Rex::Config->get("test_h")->{"name"}, "john", "setting hashRef" );
is_deeply( Rex::Config->get('test_h'), { name => 'john' }, 'check test_h' );

Rex::Config->set( "test_h", { surname => "doe" } );
ok(
  Rex::Config->get("test_h")->{"surname"} eq "doe"
    && Rex::Config->get("test_h")->{"name"} eq "john",
  "adding more to hashRef"
);
is_deeply(
  Rex::Config->get('test_h'),
  { name => 'john', surname => 'doe' },
  'check test_h'
);

1;