46 lines
887 B
Nix
46 lines
887 B
Nix
msg: {
|
|
actual,
|
|
expected ? {},
|
|
asString ? false,
|
|
asJSON ? false,
|
|
removeDunders ? false,
|
|
safeToPrint ? true,
|
|
throws ? false,
|
|
}: let
|
|
emotes = import ./emotes.nix;
|
|
|
|
preProcess = v:
|
|
if removeDunders
|
|
then undunder v
|
|
else if asString
|
|
then toString v
|
|
else if asJSON
|
|
then builtins.toJSON v
|
|
else v;
|
|
|
|
a = preProcess actual;
|
|
e = preProcess expected;
|
|
|
|
undunder = v:
|
|
if builtins.isAttrs v
|
|
then builtins.removeAttrs v ["__toString" "__functor"]
|
|
else v;
|
|
|
|
success =
|
|
builtins.trace "tix: │ ├── ${msg}"
|
|
(
|
|
if throws
|
|
then (builtins.tryEval actual).success == false
|
|
else (a == e)
|
|
);
|
|
in
|
|
{
|
|
inherit success msg;
|
|
}
|
|
// (
|
|
if success
|
|
then builtins.trace "tix: │ │ ${emotes.pass}" {}
|
|
else
|
|
builtins.trace "tix: │ │ ${emotes.fail}"
|
|
{inherit actual expected;}
|
|
)
|