generators: make toPretty handle floats correctly
This commit is contained in:
parent
5b343e7e8b
commit
455e0ed885
|
@ -143,6 +143,7 @@ rec {
|
||||||
}@args: v: with builtins;
|
}@args: v: with builtins;
|
||||||
let isPath = v: typeOf v == "path";
|
let isPath = v: typeOf v == "path";
|
||||||
in if isInt v then toString v
|
in if isInt v then toString v
|
||||||
|
else if isFloat v then "~${toString v}"
|
||||||
else if isString v then ''"${libStr.escape [''"''] v}"''
|
else if isString v then ''"${libStr.escape [''"''] v}"''
|
||||||
else if true == v then "true"
|
else if true == v then "true"
|
||||||
else if false == v then "false"
|
else if false == v then "false"
|
||||||
|
|
|
@ -369,6 +369,7 @@ runTests {
|
||||||
testToPretty = {
|
testToPretty = {
|
||||||
expr = mapAttrs (const (generators.toPretty {})) rec {
|
expr = mapAttrs (const (generators.toPretty {})) rec {
|
||||||
int = 42;
|
int = 42;
|
||||||
|
float = 0.1337;
|
||||||
bool = true;
|
bool = true;
|
||||||
string = ''fno"rd'';
|
string = ''fno"rd'';
|
||||||
path = /. + "/foo";
|
path = /. + "/foo";
|
||||||
|
@ -381,6 +382,7 @@ runTests {
|
||||||
};
|
};
|
||||||
expected = rec {
|
expected = rec {
|
||||||
int = "42";
|
int = "42";
|
||||||
|
float = "~0.133700";
|
||||||
bool = "true";
|
bool = "true";
|
||||||
string = ''"fno\"rd"'';
|
string = ''"fno\"rd"'';
|
||||||
path = "/foo";
|
path = "/foo";
|
||||||
|
|
Loading…
Reference in a new issue