branch: externals/dash
commit 5df7605da5a080df769d4f260034fb0e5e86a7a4
Author: Basil L. Contovounesios <[email protected]>
Commit: Basil L. Contovounesios <[email protected]>
Stricter defexamples checking
* dev/dash-defs.el (dash--example-to-test): Expand docstring.
(defexamples): Ensure each triple is well-formed.
* dev/examples.el (-intersection): Fix badly parenthesized cases.
---
dev/dash-defs.el | 18 ++++++++++--------
dev/examples.el | 4 ++--
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/dev/dash-defs.el b/dev/dash-defs.el
index 44795f9c73..920d3d0c19 100644
--- a/dev/dash-defs.el
+++ b/dev/dash-defs.el
@@ -53,7 +53,8 @@ differences in implementation between systems. Used in place
of
dash--epsilon)))
(defun dash--example-to-test (example)
- "Return an ERT assertion form based on EXAMPLE."
+ "Return an ERT assertion form based on EXAMPLE.
+Signal an error if EXAMPLE is malformed."
(pcase example
(`(,actual => ,expected) `(should (equal ,actual ,expected)))
(`(,actual ~> ,expected) `(should (approx= ,actual ,expected)))
@@ -75,13 +76,14 @@ See `dash--groups'."
"Define a set of EXAMPLES and corresponding ERT tests for FN.
See `dash--groups'."
(declare (indent defun))
- (setq examples (-partition 3 examples))
- `(progn
- (push (cons ',fn ',examples) dash--groups)
- (ert-deftest ,fn ()
- ;; Emacs 28.1 complains about an empty `let' body if the test
- ;; body is empty.
- ,@(or (mapcar #'dash--example-to-test examples) '(nil)))))
+ (let (triples tests)
+ (while (let ((triple (-take 3 examples)))
+ (push (dash--example-to-test triple) tests)
+ (push triple triples)
+ (setq examples (nthcdr 3 examples))))
+ `(progn
+ (push (cons ',fn ',(nreverse triples)) dash--groups)
+ (ert-deftest ,fn () ,@(nreverse tests)))))
;; Added in Emacs 25.1.
(defvar text-quoting-style)
diff --git a/dev/examples.el b/dev/examples.el
index 4006bad395..291b37dcc5 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -1356,8 +1356,8 @@ related predicates."
=> '(a b)
(let ((dash--short-list-length 0)) (-intersection '(a b) '(b a a)))
=> '(a b)
- (let ((-compare-fn #'string=)) (-intersection '(a) '("a")) => '(a))
- (let ((-compare-fn #'string=)) (-intersection '("a") '(a)) => '("a")))
+ (let ((-compare-fn #'string=)) (-intersection '(a) '("a"))) => '(a)
+ (let ((-compare-fn #'string=)) (-intersection '("a") '(a))) => '("a"))
(defexamples -powerset
(-powerset '()) => '(())