lib/generators.toPretty: Implement multiline printing
This commit is contained in:
+25
-1
@@ -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"; };
|
||||
|
||||
Reference in New Issue
Block a user