diff options
Diffstat (limited to 'lib/tests/misc.nix')
-rw-r--r-- | lib/tests/misc.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 22557bdfeefb..f40036274e81 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -285,6 +285,36 @@ runTests { expected = builtins.toJSON val; }; + testToPretty = { + expr = mapAttrs (const (generators.toPretty {})) rec { + int = 42; + bool = true; + string = "fnord"; + null_ = null; + function = x: x; + list = [ 3 4 function [ false ] ]; + attrs = { foo = null; "foo bar" = "baz"; }; + drv = derivation { name = "test"; system = builtins.currentSystem; }; + }; + expected = rec { + int = "42"; + bool = "true"; + string = "\"fnord\""; + null_ = "null"; + function = "<λ>"; + list = "[ 3 4 ${function} [ false ] ]"; + attrs = "{ \"foo\" = null; \"foo bar\" = \"baz\"; }"; + drv = "<δ>"; + }; + }; + + testToPrettyAllowPrettyValues = { + expr = generators.toPretty { allowPrettyValues = true; } + { __pretty = v: "«" + v + "»"; val = "foo"; }; + expected = "«foo»"; + }; + + # MISC testOverridableDelayableArgsTest = { |