second thought about testing:
if I did that, it would become longer than 15 lines, I would need
refactoring quite a bit of stuff, and both things would require time,
bureaucratic time, and programming time.
I had a closer look at my changes, re-read it, and used it a bit, and I
think this is o.k.
see it yourself, when we have the agreement allowing you accept changes
longer than 15 lines, I'll consider the needed refactoring and test-writing.
ciao,
Mario
On 15/06/2020 09:49, Mario Frasca wrote:
Hi Nicolas, I think that the hint on testing is very correct, I'm
afraid I changed the semantics of one of the original tests, and I
found that there's other cl functions other than just cl-some, also
cl-every, cl-notevery, and cl-notany. I'll have a closer look at
this. and write some tests before changing the code.
I also looked for the strange idiom used here, and these two are the
only two locations I found.
how do I run tests from the command line (I'm using make test) but
then limited to one lisp file? or one specific test?
ciao,
Mario
On 14/06/2020 14:32, Nicolas Goaziou wrote:
[…]
Also, further nit: (not (cl-every ...)) will apply `not' only once.
In any case, it would be better if refactoring happens while introducing
unit tests *hint*.
Regards,
>From 49f1cfbb80a3d5ffdbac4eea60bb3d45991c4423 Mon Sep 17 00:00:00 2001
From: mfrasca <ma...@anche.no>
Date: Sun, 14 Jun 2020 10:52:41 -0500
Subject: [PATCH] lisp/org-plot.el: reducing complexity of test.
* lisp/org-plot.el (org-plot/gnuplot): readability of test, looking
for some non satisfying elements.
I'm rewriting a complicated construction where there's an equality
test on the length of the list of non matching elements, with a
simpler cl-some invocation. The replacing code is self explanatory.
---
lisp/org-plot.el | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index a23195d2a..bf81d3c37 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -309,26 +309,20 @@ line directly before or after the table."
(`grid (let ((y-labels (org-plot/gnuplot-to-grid-data
table data-file params)))
(when y-labels (plist-put params :ylabels y-labels)))))
- ;; Check for timestamp ind column.
- (let ((ind (1- (plist-get params :ind))))
- (when (and (>= ind 0) (eq '2d (plist-get params :plot-type)))
- (if (= (length
- (delq 0 (mapcar
- (lambda (el)
- (if (string-match org-ts-regexp3 el) 0 1))
- (mapcar (lambda (row) (nth ind row)) table))))
- 0)
- (plist-put params :timeind t)
- ;; Check for text ind column.
- (if (or (string= (plist-get params :with) "hist")
- (> (length
- (delq 0 (mapcar
- (lambda (el)
- (if (string-match org-table-number-regexp el)
- 0 1))
- (mapcar (lambda (row) (nth ind row)) table))))
- 0))
- (plist-put params :textind t)))))
+ ;; Check type of ind column (timestamp? text?)
+ (when (eq `2d (plist-get params :plot-type))
+ (let* ((ind (1- (plist-get params :ind)))
+ (ind-column (mapcar (lambda (row) (nth ind row)) table)))
+ (cond ((< ind 0) nil) ; ind is implicit
+ ((cl-every (lambda (el)
+ (string-match org-ts-regexp3 el))
+ ind-column)
+ (plist-put params :timeind t)) ; ind holds timestamps
+ ((or (string= (plist-get params :with) "hist")
+ (cl-notevery (lambda (el)
+ (string-match org-table-number-regexp el))
+ ind-column))
+ (plist-put params :textind t))))) ; ind holds text
;; Write script.
(with-temp-buffer
(if (plist-get params :script) ; user script
--
2.20.1