branch: externals/tomelr commit c872e9efc1bcf0d9310160f825032c602500c346 Author: Kaushal Modi <kaushal.m...@gmail.com> Commit: Kaushal Modi <kaushal.m...@gmail.com>
test: Add test for integer scalar key-value pairs --- README.org | 63 ++++++++++++++++++++++++++++++++------------------------- test/tscalar.el | 15 ++++++++++++++ 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/README.org b/README.org index 1682bf52f5..10368005c4 100644 --- a/README.org +++ b/README.org @@ -21,8 +21,8 @@ specification defined below. * Library Completion Status [0/6] - [-] Scalar - [X] Boolean + - [X] Integer - [ ] String - - [ ] Integer - [ ] Float - [ ] Date + Time with Offset - [ ] Date @@ -47,14 +47,16 @@ https://toml.io/en/v1.0.0#boolean (bool2 . :false)) #+end_src **** TOML -#+begin_src emacs-lisp :noweb yes :exports results +#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml (tomelr-encode <<scalar-boolean>>) #+end_src #+RESULTS: -: bool1 = true -: bool2 = false +#+begin_src toml +bool1 = true +bool2 = false +#+end_src **** JSON Reference #+begin_src emacs-lisp :noweb yes :exports results (json-encode-pretty @@ -66,29 +68,8 @@ https://toml.io/en/v1.0.0#boolean : "bool1": true, : "bool2": false : } -*** 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" -: } -*** Integer +*** DONE Integer +CLOSED: [2022-04-28 Thu 17:11] https://toml.io/en/v1.0.0#integer **** S-expression #+begin_src emacs-lisp :eval no :noweb-ref scalar-integer @@ -98,6 +79,12 @@ https://toml.io/en/v1.0.0#integer (int4 . -17)) #+end_src **** TOML +#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml +(tomelr-encode + <<scalar-integer>>) +#+end_src + +#+RESULTS: #+begin_src toml int1 = 99 int2 = 42 @@ -117,6 +104,28 @@ 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 https://toml.io/en/v1.0.0#float **** S-expression diff --git a/test/tscalar.el b/test/tscalar.el index 695dfcc4f0..b3cbe62137 100644 --- a/test/tscalar.el +++ b/test/tscalar.el @@ -38,5 +38,20 @@ (push (tomelr-encode el) out)) (should (equal ref (nreverse out))))) +;;;; Scalar - Integer +(ert-deftest test-scalar-int () + (let ((inp '(((int1 . +99)) + ((int2 . 42)) + ((int3 . 0)) + ((int4 . -17)))) + (ref '("int1 = 99" + "int2 = 42" + "int3 = 0" + "int4 = -17")) + out) + (dolist (el inp) + (push (tomelr-encode el) out)) + (should (equal ref (nreverse out))))) + (provide 'tscalar)