-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.nix
29 lines (28 loc) · 1.03 KB
/
tests.nix
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
let
select = (import ./select.nix).select;
testdata = {
somedict = {
hello = "world";
foo = {
something.x = "hi";
something.y = "there";
something.z = "sup";
};
"foo.bar" = "baz";
};
somelists = [
{ name = "foo"; data.a = ":)"; }
{ name = "bar"; data.b = ":|"; }
{ name = "baz"; data.c = ":("; }
];
};
in
{
listSingle = assert ((select "somelists.0.name" testdata) == "foo"); true;
listAll = assert ((select "somelists.*.name" testdata) == [ "foo" "bar" "baz" ]); true;
listMulti = assert ((select "somelists.{0,2}.name" testdata) == [ "foo" "baz" ]); true;
dictSingle = assert ((select "somedict.hello" testdata) == "world"); true;
dictQuoted = assert ((select ''somedict."foo.bar"'' testdata) == "baz"); true;
dictMulti = assert ((select "somedict.foo.something.{x,y}" testdata) == { x = "hi"; y = "there";}); true;
dictAll = assert ((select "somedict.foo.something.*" testdata) == { x = "hi"; y = "there"; z = "sup";}); true;
}