test(engine): cover zero and negative whole-number floats in toToml

Add a regression case exercising float64(0), float64(-7), and the
negative fractional float64(-3.25) so the normalization is exercised
across the full int64 range (not just positive values) and so negative
fractional floats are shown to still round-trip as TOML floats.

Requested by @TerryHowe on #32040.

Signed-off-by: barry3406 <duan3406@gmail.com>
pull/32040/head
barry3406 3 months ago
parent 0c8ab13223
commit 8773bccb21

@ -112,6 +112,17 @@ keyInElement1 = "valueInElement1"`,
tpl: `{{ toToml . }}`,
expect: "big = 1e+20\n",
vars: map[string]any{"big": float64(1e20)},
}, {
// Regression for https://github.com/helm/helm/issues/32035
// Zero and negative whole-number floats must also render as TOML
// integers, and negative fractional floats must stay floats.
tpl: `{{ toToml . }}`,
expect: "neg = -7\nnegFrac = -3.25\nzero = 0\n",
vars: map[string]any{
"zero": float64(0),
"neg": float64(-7),
"negFrac": float64(-3.25),
},
}, {
tpl: `{{ fromYaml . }}`,
expect: "map[Error:error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go value of type map[string]interface {}]",

Loading…
Cancel
Save