Skip to content

Commit

Permalink
test: Add test for TOML Array of Arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Apr 29, 2022
1 parent 0ba5f2f commit f37841c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
17 changes: 12 additions & 5 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the Emacs core library [[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/j

It will then be gradually refactored so that it meets the
specification defined below.
* Library Completion Status [3/7]
* Library Completion Status [4/7]
- [X] Scalar
- [X] Boolean
- [X] Integer
Expand All @@ -28,7 +28,7 @@ specification defined below.
- [X] Date + Time with Offset
- [X] Nil
- [X] Arrays
- [ ] Array of Arrays
- [X] Array of Arrays
- [ ] Tables
- [ ] Array of Tables
- [ ] Property Lists
Expand Down Expand Up @@ -337,16 +337,23 @@ numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
]
}
#+end_example
*** Array of Arrays
*** DONE Array of Arrays
CLOSED: [2022-04-29 Fri 00:34]
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref array-of-arrays
'((nested_arrays_of_ints . [(1 2) (3 4 5)])
(nested_mixed_array . [(1 2) ("a" "b" "c")]))
#+end_src
**** TOML
#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml
(tomelr-encode
<<array-of-arrays>>)
#+end_src

#+RESULTS:
#+begin_src toml
nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ]
nested_arrays_of_ints = [ [ 1, 2 ], [ 3, 4, 5 ] ]
nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
#+end_src
**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
Expand Down
13 changes: 12 additions & 1 deletion test/tarray.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
;;; Code:
(require 'tomelr)

;;;; Key with array value
;;;; Simple arrays
(ert-deftest test-array ()
(let ((inp '(((integers . (1 2 3)))
((integers2 . [1 2 3])) ;Same as above
Expand All @@ -39,5 +39,16 @@
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))

;;;; Array of arrays
(ert-deftest test-array-of-arrays ()
(let ((inp '(((nested_arrays_of_ints . [(1 2) (3 4 5)]))
((nested_mixed_array . [(1 2) ("a" "b" "c")]))))
(ref '("nested_arrays_of_ints = [ [ 1, 2 ], [ 3, 4, 5 ] ]"
"nested_mixed_array = [ [ 1, 2 ], [ \"a\", \"b\", \"c\" ] ]"))
out)
(dolist (el inp)
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))


(provide 'tarray)

0 comments on commit f37841c

Please sign in to comment.