From 7a3c5681cef680407a71e7d27396ab987320908c Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Thu, 18 Nov 2021 02:18:22 +0530 Subject: [PATCH] Write currently-failing plist-pp-to-string test --- elisp/chronometrist.el | 3 +++ elisp/chronometrist.org | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/elisp/chronometrist.el b/elisp/chronometrist.el index 8c8b9d1..08a966f 100644 --- a/elisp/chronometrist.el +++ b/elisp/chronometrist.el @@ -757,6 +757,9 @@ FS-EVENT is the event passed by the `filenotify' library (see `file-notify-add-w (cl-defgeneric chronometrist-memory-layer-empty-p (backend) "Return non-nil if memory layer of BACKEND contains no records, else nil.") +(cl-defgeneric chronometrist-verify (backend) + "Check BACKEND for errors in data.") + (defclass chronometrist-file-backend-mixin () ((path ;; :initform (error "Path is required") :initarg :path diff --git a/elisp/chronometrist.org b/elisp/chronometrist.org index 495fae5..32f8c8f 100644 --- a/elisp/chronometrist.org +++ b/elisp/chronometrist.org @@ -1279,8 +1279,22 @@ IN-SUBLIST, if non-nil, means point is inside an inner list." " :tags (warm-up)\n" " :start \"2018-11-21T15:35:04+0530\"\n" " :stop \"2018-11-21T15:38:41+0530\"\n" - " :comment (\"stretching\" (25 10 \"push-ups\")))")))) + " :comment (\"stretching\" (25 10 \"push-ups\")))"))) + (should (equal + (chronometrist-plist-pp-to-string + '(:name "Guitar" + :tags (classical) + :warm-up ((right-hand-patterns "pima" "piam" "pmia" "pmai" "pami" "paim")) + :start "2021-09-28T17:49:18+0530" + :stop "2021-09-28T17:53:49+0530")) + (concat + "(:name \"Guitar\"\n" + " :tags (classical)\n" + " :warm-up ((right-hand-patterns \"pima\" \"piam\" \"pmia\" \"pmai\" \"pami\" \"paim\"))\n" + " :start \"2021-09-28T17:49:18+0530\"\n" + " :stop \"2021-09-28T17:53:49+0530\")")))) #+END_SRC + *** buffer-plist :writer: #+BEGIN_SRC emacs-lisp (defun chronometrist-plist-pp-buffer-plist (&optional in-sublist) @@ -1582,6 +1596,12 @@ FS-EVENT is the event passed by the `filenotify' library (see `file-notify-add-w "Return non-nil if memory layer of BACKEND contains no records, else nil.") #+END_SRC +**** verify :generic:function: +#+BEGIN_SRC emacs-lisp +(cl-defgeneric chronometrist-verify (backend) + "Check BACKEND for errors in data.") +#+END_SRC + *** Common definitions for s-expression backends **** file-backend-mixin :mixin: :PROPERTIES: @@ -2346,8 +2366,7 @@ We just want to insert a plist, but as a hack to avoid updating the pretty-print **** to-list :reader:method: #+BEGIN_SRC emacs-lisp (cl-defmethod chronometrist-to-list ((backend chronometrist-plist-group-backend)) - (chronometrist-loop-sexp-file for expr in (chronometrist-backend-file backend) - append (rest expr))) + (chronometrist-loop-sexp-file for expr in (chronometrist-backend-file backend) append (rest expr))) #+END_SRC **** to-hash-table :reader:method: