From 5a8fb0af4034263d3b3483a711e88f556f80ec8f Mon Sep 17 00:00:00 2001 From: Mark Skilbeck Date: Thu, 20 Jun 2019 18:49:49 -0700 Subject: [PATCH] Serialize rationals as floats Deserializing also produces floats. --- src-tests/suite.lisp | 6 ++++-- src/rpcq.lisp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src-tests/suite.lisp b/src-tests/suite.lisp index f8e6ef1..00b10ae 100644 --- a/src-tests/suite.lisp +++ b/src-tests/suite.lisp @@ -73,9 +73,11 @@ (deftest test-serialize-deserialize () (let* ((original (make-instance 'rpcq::|RPCRequest| :|method| "test-method" - :|params| (make-hash-table) + :|params| (alexandria:alist-hash-table + '(("one-half" . 1/2))) :|id| "test-id")) (cloned (rpcq::deserialize (rpcq::serialize original)))) (is (typep cloned 'rpcq::|RPCRequest|)) (is (string= (rpcq::|RPCRequest-id| original) (rpcq::|RPCRequest-id| cloned))) - (is (string= (rpcq::|RPCRequest-method| original) (rpcq::|RPCRequest-method| cloned))))) + (is (string= (rpcq::|RPCRequest-method| original) (rpcq::|RPCRequest-method| cloned))) + (is (= 0.5 (gethash "one-half" (rpcq::|RPCRequest-params| cloned)))))) diff --git a/src/rpcq.lisp b/src/rpcq.lisp index d1b5e05..6c8fc8e 100644 --- a/src/rpcq.lisp +++ b/src/rpcq.lisp @@ -95,6 +95,9 @@ The input strings are assumed to be FORMAT-compatible, so sequences like ~