From 65f5c7583637f03a08a1737d5851f06a472a6dd6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 8 Nov 2018 16:02:09 +0000 Subject: [PATCH] Fix reader NaN notation: -nan.0/+nan.0, not just nan.0. --- src/runtime/numpar.scm | 3 ++- src/runtime/reader.scm | 4 +--- tests/runtime/test-readwrite.scm | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/runtime/numpar.scm b/src/runtime/numpar.scm index d995b14fd..d30010b4c 100644 --- a/src/runtime/numpar.scm +++ b/src/runtime/numpar.scm @@ -34,7 +34,8 @@ USA. (end (fix:end-index end (string-length string) caller)) (start (fix:start-index start end caller)) (z - (cond ((string=? string "nan.0") (flo:nan.0)) + (cond ((string=? string "+nan.0") (flo:nan.0)) + ((string=? string "-nan.0") (flo:nan.0)) ((string=? string "+inf.0") (flo:+inf.0)) ((string=? string "-inf.0") (flo:-inf.0)) (else diff --git a/src/runtime/reader.scm b/src/runtime/reader.scm index 84c051a51..31159075d 100644 --- a/src/runtime/reader.scm +++ b/src/runtime/reader.scm @@ -433,9 +433,7 @@ USA. ctx (let ((string (read-atom db (list char)))) (or (maybe-keyword db string) - (if (string=? string "nan.0") - (flo:nan.0) - (make-symbol db string))))) + (make-symbol db string)))) (define (maybe-keyword db string) (cond ((and (eq? 'suffix (db-keyword-style db)) diff --git a/tests/runtime/test-readwrite.scm b/tests/runtime/test-readwrite.scm index 9e2a50e00..52f45b4e3 100644 --- a/tests/runtime/test-readwrite.scm +++ b/tests/runtime/test-readwrite.scm @@ -70,7 +70,7 @@ USA. `(("+inf.0" ,assert-inf+) ("-inf.0" ,assert-inf-) ("inf.0" ,assert-symbol) - ("nan.0" ,assert-symbol xfail)) + ("nan.0" ,assert-symbol)) (lambda (string #!optional assertion xfail?) (with-expected-failure xfail? (lambda () @@ -79,8 +79,8 @@ USA. (assert-equal (write-to-string object) string)))))) (define-enumerated-test 'read - `(("+nan.0" ,assert-nan xfail) - ("-nan.0" ,assert-nan xfail)) + `(("+nan.0" ,assert-nan) + ("-nan.0" ,assert-nan)) (lambda (string assertion #!optional xfail?) (with-expected-failure xfail? (lambda () -- 2.25.1