gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 06/07: value-parser: Recognise negative floating-point n


From: gnunet
Subject: [gnunet-scheme] 06/07: value-parser: Recognise negative floating-point numbers.
Date: Sun, 28 Aug 2022 22:03:12 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit e9e9b59aad4b4ef763a9e5442f92d1579a535cd8
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sun Aug 28 21:58:24 2022 +0200

    value-parser: Recognise negative floating-point numbers.
    
    * gnu/gnunet/config/value-parser.scm (float-regex): Allow - prefixes.
    * tests/config-value-parser.scm
    ("value->float, negative 0 (a)"): Unskip.
    ("value->float, negative 0 (b)"): Unskip.
    ("value->float, negative 0 (c)"): Unskip.
---
 gnu/gnunet/config/value-parser.scm | 3 ++-
 tests/config-value-parser.scm      | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/gnunet/config/value-parser.scm 
b/gnu/gnunet/config/value-parser.scm
index e459702..65bf994 100644
--- a/gnu/gnunet/config/value-parser.scm
+++ b/gnu/gnunet/config/value-parser.scm
@@ -97,8 +97,9 @@ In case of a parse error, raise an appropriate
          (raise (make-value-parse/natural-error text))
          (string->number text)))
 
+    ;; TODO: should +1.4 be accepted?
     (define float-regex
-      (make-regexp "^((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)$"))
+      (make-regexp "^(-)?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)$"))
 
     (define (value->float text)
       "Parse @var{text} as a floating-point number.
diff --git a/tests/config-value-parser.scm b/tests/config-value-parser.scm
index 3bf1a43..6f272b3 100644
--- a/tests/config-value-parser.scm
+++ b/tests/config-value-parser.scm
@@ -112,7 +112,6 @@
   0.0
   (value->float "0"))
 
-(test-expect-fail 4)
 (test-eqv "value->float, negative 0 (a)"
   -0.0
   (value->float "-0.0"))
@@ -122,6 +121,7 @@
 (test-eqv "value->float, negative 0 (c)"
   -0.0
   (value->float "-.0"))
+(test-expect-fail 1)
 (test-eqv "value->float, negative 0 (d)"
   -0.0
   (value->float "-0"))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]