From 3f6d1998b60e2778730a925d2b761db3b54979fe Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 Jan 2022 10:41:37 +0100 Subject: vallist: uc_number_parse(): parse empty strings as `0`, not `NaN` Fixes: b605dbf ("treewide: rework numeric value handling") Signed-off-by: Jo-Philipp Wich --- tests/custom/04_bugs/29_empty_string_as_number | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/custom/04_bugs/29_empty_string_as_number (limited to 'tests/custom/04_bugs') diff --git a/tests/custom/04_bugs/29_empty_string_as_number b/tests/custom/04_bugs/29_empty_string_as_number new file mode 100644 index 0000000..675f8a1 --- /dev/null +++ b/tests/custom/04_bugs/29_empty_string_as_number @@ -0,0 +1,17 @@ +When an empty string was casted to a number, e.g. explicitly through `+` +or `int()` or implicitly through numerical calculations, it was incorrectly +treated as `NaN` and not `0`. + +-- Testcase -- +{{ +"" }} +{{ int("") }} +{{ "" + 0 }} +{{ "" - 0.0 }} +-- End -- + +-- Expect stdout -- +0 +0 +0 +0 +-- End -- -- cgit v1.2.3