aboutsummaryrefslogtreecommitdiff
path: root/t/getting.t
blob: e4339bb23f32ac57c8ab5c0791c181795b9d39eb (plain)
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
#! /usr/bin/env perl6

use v6.c;
use Test;
use lib "lib";

plan 6;

use Config;

my $config = Config.new();

$config.read({
    a => "a",
    b => {
        c => "c"
    }
});

ok $config.get("a") eq "a", "Get simple key";
ok $config.get("b.c") eq "c", "Get nested key";
ok $config.get("nonexistant") === Nil, "Get nonexistant key";
ok $config.get("nonexistant", "test") === Nil, "Get nonexistant key with default";

ok $config.get(["a"]) eq "a", "Get simple key by array";
ok $config.get(["b", "c"]) eq "c", "Get nested key by array";
ok $config.get(["nonexistant"]) === Nil, "Get nonexistant key by array";
ok $config.get(["nonexistant"], "test") === Nil, "Get nonexistant key by array with default";