-
Notifications
You must be signed in to change notification settings - Fork 3
/
19-properties.rakutest
48 lines (42 loc) · 1.41 KB
/
19-properties.rakutest
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
use Test;
use lib 'lib';
use App::Racoco::Properties;
use lib 't/lib';
use TestResources;
use TestHelper;
plan 3;
my $lib;
sub setup($lib-name = 'lib') {
plan $*plan;
TestResources::prepare($*subtest);
$lib = TestResources::exam-directory.add($lib-name);
}
'01-parse-command-line'.&test(:3plan, {
setup();
my $actual := Properties.parse-command-line('foo:bar;one :t w o ;');
is $actual.elems, 2, 'parsed elems';
is $actual<foo>, 'bar', 'parsed no spases';
is $actual<one>, 't w o', 'parsed with spases';
});
'02-all-properties'.&test(:6plan, {
setup();
%*ENV<from-command-line> = 'env: overridden';
%*ENV<from-env> = 'env value';
my $properties = Properties.new(
:$lib,
mode => 'good-section',
command-line => 'from-command-line:command-line value',
);
is $properties.env-only('from-command-line'), 'env: overridden', 'env => command-line';
is $properties.property('from-command-line'), 'command-line value', 'command-line > env';
is $properties.property('from-env'), 'env value', 'env > config';
is $properties.property('from-top-section'), 'top value', 'top > Any';
is $properties.property('from-good-section'), 'good value', 'good > top';
nok $properties.property('not-exists'), 'not exists';
});
'03-empty-config'.&test(:2plan, {
setup();
my $properties = Properties.new(:$lib);
nok $properties.property('not-exists'), 'not exists config';
nok $properties.env-only('not-exists'), 'not exists env';
});