branch: externals/tomelr commit 9c91e0dc07291aae8a8b2b4dd1cea52583165e14 Author: Kaushal Modi <kaushal.m...@gmail.com> Commit: Kaushal Modi <kaushal.m...@gmail.com>
test: Add test for float scalar key-value pairs --- README.org | 64 +++++++++++++++++++++++++++++---------------------------- test/tscalar.el | 21 +++++++++++++++++++ 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/README.org b/README.org index 10368005c4..176979b7ed 100644 --- a/README.org +++ b/README.org @@ -22,8 +22,8 @@ specification defined below. - [-] Scalar - [X] Boolean - [X] Integer + - [X] Float - [ ] String - - [ ] Float - [ ] Date + Time with Offset - [ ] Date - [ ] Nil @@ -104,29 +104,8 @@ int4 = -17 : "int3": 0, : "int4": -17 : } -*** String -https://toml.io/en/v1.0.0#string -**** S-expression -#+begin_src emacs-lisp :eval no :noweb-ref scalar-string -'((str . "Roses are red\nViolets are blue")) -#+end_src -**** TOML -#+begin_src toml -str = """ -Roses are red -Violets are blue""" -#+end_src -**** JSON Reference -#+begin_src emacs-lisp :noweb yes :exports results -(json-encode-pretty - <<scalar-string>>) -#+end_src - -#+RESULTS: -: { -: "str": "Roses are red\nViolets are blue" -: } -*** Float +*** DONE Float +CLOSED: [2022-04-28 Thu 17:29] https://toml.io/en/v1.0.0#float **** S-expression #+begin_src emacs-lisp :eval no :noweb-ref scalar-float @@ -139,18 +118,19 @@ https://toml.io/en/v1.0.0#float (flt7 . 6.626e-34)) #+end_src **** TOML +#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml +(tomelr-encode + <<scalar-float>>) +#+end_src + +#+RESULTS: #+begin_src toml -# fractional flt1 = 1.0 flt2 = 3.1415 flt3 = -0.01 - -# exponent flt4 = 5e+22 -flt5 = 1e06 -flt6 = -2E-2 - -# both +flt5 = 1000000.0 +flt6 = -0.02 flt7 = 6.626e-34 #+end_src **** JSON Reference @@ -169,6 +149,28 @@ flt7 = 6.626e-34 : "flt6": -0.02, : "flt7": 6.626e-34 : } +*** String +https://toml.io/en/v1.0.0#string +**** S-expression +#+begin_src emacs-lisp :eval no :noweb-ref scalar-string +'((str . "Roses are red\nViolets are blue")) +#+end_src +**** TOML +#+begin_src toml +str = """ +Roses are red +Violets are blue""" +#+end_src +**** JSON Reference +#+begin_src emacs-lisp :noweb yes :exports results +(json-encode-pretty + <<scalar-string>>) +#+end_src + +#+RESULTS: +: { +: "str": "Roses are red\nViolets are blue" +: } *** Date + Time with Offset https://toml.io/en/v1.0.0#offset-date-time **** S-expression diff --git a/test/tscalar.el b/test/tscalar.el index b3cbe62137..a052eff7db 100644 --- a/test/tscalar.el +++ b/test/tscalar.el @@ -53,5 +53,26 @@ (push (tomelr-encode el) out)) (should (equal ref (nreverse out))))) +;;;; Scalar - Float +(ert-deftest test-scalar-float () + (let ((inp '(((float1 . +1.0)) + ((float2 . 3.1415)) + ((float3 . -0.01)) + ((float4 . 5e+22)) + ((float5 . 1e06)) + ((float6 . -2E-2)) + ((float7 . 6.626e-34)))) + (ref '("float1 = 1.0" + "float2 = 3.1415" + "float3 = -0.01" + "float4 = 5e+22" + "float5 = 1000000.0" + "float6 = -0.02" + "float7 = 6.626e-34")) + out) + (dolist (el inp) + (push (tomelr-encode el) out)) + (should (equal ref (nreverse out))))) + (provide 'tscalar)