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