aboutsummaryrefslogtreecommitdiff
path: root/t/10-template.t
blob: 3baa15b09182acb329832e10cdd1239090ab1409 (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
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
#!/usr/bin/env raku

use v6.d;

use Test;

use Config;

plan 2;

subtest 'Flat template', {
	plan 6;

	my $config = Config.new({
		foo => Any,
		bar => Any,
	}, :name<raku-config>);

	ok $config, 'Config object instantiated';

	ok $config.has('foo'), 'Config contains "foo"';
	ok $config.has('bar'), 'Config contains "bar"';

	nok $config.has('alpha'), 'Config does not contain "alpha"';
	nok $config.has('beta'), 'Config does not contain "beta"';

	is $config.keys.sort, < bar foo >, 'Config.keys is correct';
}

subtest 'Nested template', {
	plan 7;

	my $config = Config.new({
		foo => {
			alpha => Any,
		},
		bar => {
			beta => Any,
		},
		baz => Any,
	}, :name<raku-config>);

	ok $config, 'Config object instantiated';

	ok $config.has('foo'), 'Config contains "foo"';
	ok $config.has('foo.alpha'), 'Config contains "foo.alpha"';
	ok $config.has('baz'), 'Config contains "baz"';

	nok $config.has('omega.phi'), 'Config does not contain "omega.phi"';
	nok $config.has('omega'), 'Config does not contain "omega"';

	is $config.keys.sort, < bar.beta baz foo.alpha >, 'Config.keys is correct';
}