summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/99_bugs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-10-16 12:09:31 +0200
committerJo-Philipp Wich <jo@mein.io>2024-10-16 12:09:31 +0200
commit4134e7182624b37bf17d91fc89b500f5cb443187 (patch)
tree5a4878d66d02b9f832e34096574083e409fd2858 /tests/custom/99_bugs
parent9cf53dda36bc25b513ec1b1cdfc851a10b37473f (diff)
vallist: more thoroughly check for trailing garbage after numeric string
When converting numeric strings into numbers, ensure that only optional trailing whitespace follows and no other characters. Fixes: #231 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/99_bugs')
-rw-r--r--tests/custom/99_bugs/49_trailing_garbage_string_as_number23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/custom/99_bugs/49_trailing_garbage_string_as_number b/tests/custom/99_bugs/49_trailing_garbage_string_as_number
new file mode 100644
index 0000000..1b48146
--- /dev/null
+++ b/tests/custom/99_bugs/49_trailing_garbage_string_as_number
@@ -0,0 +1,23 @@
+Ensure that numeric strings followed by non-whitespace are treated as NaN.
+
+-- Testcase --
+{%
+printf("%.J\n", [
+ "1" == 1,
+ " 1" == 1,
+ "1 " == 1,
+ "1a" == 1,
+ "1 a" == 1
+]);
+%}
+-- End --
+
+-- Expect stdout --
+[
+ true,
+ true,
+ true,
+ false,
+ false
+]
+-- End --