5 /* Print a trace message if pred is false.
6 Intended to be used to augment asserts with helpful error messages.
13 assert (assertMsg ("foo" == "bar") "foo is not bar, silly"); ""
14 stderr> trace: foo is not bar, silly
15 stderr> assert failed at …
18 assertMsg :: Bool -> String -> Bool
20 # TODO(Profpatsch): add tests that check stderr
21 assertMsg = pred: msg:
24 else builtins.trace msg false;
26 /* Specialized `assertMsg` for checking if val is one of the elements
27 of a list. Useful for checking enums.
30 let sslLibrary = "libressl"
31 in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
33 stderr> trace: sslLibrary must be one of "openssl", "bearssl", but is: "libressl"
36 assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
38 assertOneOf = name: val: xs: assertMsg
40 "${name} must be one of ${
41 lib.generators.toPretty {} xs}, but is: ${
42 lib.generators.toPretty {} val}";
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list