From 8773bccb2153fb7c4106f9d948953d9dd9bf106a Mon Sep 17 00:00:00 2001 From: barry3406 Date: Thu, 16 Apr 2026 11:28:30 -0700 Subject: [PATCH] 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 --- pkg/engine/funcs_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/engine/funcs_test.go b/pkg/engine/funcs_test.go index a76a9810b..00ffc8fdb 100644 --- a/pkg/engine/funcs_test.go +++ b/pkg/engine/funcs_test.go @@ -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 {}]",