diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-09-04 17:46:12 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-09-17 18:20:25 +0200 |
commit | 47f2eb89c16a74881c6e1a3b18290bf3d0f94a60 (patch) | |
tree | 8537b2a481f60276bd5f1bc2679ca2380f171a59 /lib/tests | |
parent | 4811f54e94756d8a83ee9fb439e56675033923ae (diff) |
lib/generators.toPretty: Implement multiline printing
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/misc.nix | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 7d7380e8b74bd..4fed8ef01c943 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -446,7 +446,7 @@ runTests { }; testToPretty = { - expr = mapAttrs (const (generators.toPretty {})) rec { + expr = mapAttrs (const (generators.toPretty { multiline = false; })) rec { int = 42; float = 0.1337; bool = true; @@ -474,6 +474,30 @@ runTests { }; }; + testToPrettyMultiline = { + expr = mapAttrs (const (generators.toPretty { })) rec { + list = [ 3 4 [ false ] ]; + attrs = { foo = null; bar.foo = "baz"; }; + }; + expected = rec { + list = '' + [ + 3 + 4 + [ + false + ] + ]''; + attrs = '' + { + bar = { + foo = "baz"; + }; + foo = null; + }''; + }; + }; + testToPrettyAllowPrettyValues = { expr = generators.toPretty { allowPrettyValues = true; } { __pretty = v: "«" + v + "»"; val = "foo"; }; |