1{ test, lib, ...}:
2{
3 equal = expected: actual:
4 if actual == expected then
5 (test.passed "= ${toString expected}") else
6 (test.failed (
7 "expected '${toString expected}'(${builtins.typeOf expected})"
8 + " != "+
9 "actual '${toString actual}'(${builtins.typeOf actual})"
10 ));
11
12 beASet = actual:
13 if builtins.isAttrs actual then
14 (test.passed "is a set") else
15 (test.failed "is not a set, was ${builtins.typeOf actual}: ${toString actual}");
16
17 haveKeys = expected: actual:
18 if builtins.all
19 (ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
20 expected then
21 (test.passed "has expected keys") else
22 (test.failed "keys differ: expected: [${lib.concatStringsSep ";" expected}] actual: [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
23
24 havePrefix = expected: actual:
25 if lib.hasPrefix expected actual then
26 (test.passed "has prefix '${expected}'") else
27 (test.failed "prefix '${expected}' not found in '${actual}'");
28}