lib/generators.toPretty: Implement multiline printing

This commit is contained in:
Silvan Mosberger
2020-09-17 18:20:25 +02:00
parent 4811f54e94
commit 47f2eb89c1
2 changed files with 40 additions and 11 deletions
+25 -1
View File
@@ -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"; };