summaryrefslogtreecommitdiffhomepage
path: root/tests/custom
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-01-26 10:41:37 +0100
committerJo-Philipp Wich <jo@mein.io>2022-01-26 10:47:56 +0100
commit3f6d1998b60e2778730a925d2b761db3b54979fe (patch)
tree3150ccd20772ee2406d3024a9b930f6051f6c028 /tests/custom
parentaa860a35252b4833a188f8b2f9c6a7d68963767d (diff)
vallist: uc_number_parse(): parse empty strings as `0`, not `NaN`
Fixes: b605dbf ("treewide: rework numeric value handling") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom')
-rw-r--r--tests/custom/04_bugs/29_empty_string_as_number17
1 files changed, 17 insertions, 0 deletions
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 --