[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cfc1779f467: * Better type comparison in comp tests
From: |
Andrea Corallo |
Subject: |
master cfc1779f467: * Better type comparison in comp tests |
Date: |
Mon, 29 Jan 2024 15:25:01 -0500 (EST) |
branch: master
commit cfc1779f4676b1be3ff34abc913e97a1b2a7de37
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>
* Better type comparison in comp tests
* test/src/comp-tests.el (comp-tests--type-lists-equal): New function.
(comp-tests--types-equal): Handle function types.
---
test/src/comp-tests.el | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index 54a9a6c11cc..fbcb6ca9560 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -904,16 +904,23 @@ Return a list of results."
(should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f)))
(should (= (comp-tests-fw-prop-1-f) 6))))
+(defun comp-tests--type-lists-equal (l1 l2)
+ (and (= (length l1) (length l2))
+ (cl-every #'comp-tests--types-equal l1 l2)))
+
(defun comp-tests--types-equal (t1 t2)
- "Whether the types T1 and T2 are equal."
- (or (equal t1 t2) ; optimization for the common case
- (and (consp t1) (consp t2)
- (eq (car t1) (car t2))
- (if (memq (car t1) '(and or member))
- (null (cl-set-exclusive-or (cdr t1) (cdr t2)
- :test #'comp-tests--types-equal))
- (and (= (length t1) (length t2))
- (cl-every #'comp-tests--types-equal (cdr t1) (cdr t2)))))))
+ "Whether the types T1 and T2 are equal."
+ (or (equal t1 t2) ; for atoms, and optimization for the common case
+ (and (consp t1) (consp t2)
+ (eq (car t1) (car t2))
+ (cond ((memq (car t1) '(and or member))
+ ;; Order or duplicates don't matter.
+ (null (cl-set-exclusive-or (cdr t1) (cdr t2)
+ :test #'comp-tests--types-equal)))
+ ((eq (car t1) 'function)
+ (and (comp-tests--type-lists-equal (nth 1 t1) (nth 1 t2))
+ (comp-tests--types-equal (nth 2 t1) (nth 2 t2))))
+ (t (comp-tests--type-lists-equal (cdr t1) (cdr t2)))))))
(defun comp-tests-check-ret-type-spec (func-form ret-type)
(let ((lexical-binding t)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master cfc1779f467: * Better type comparison in comp tests,
Andrea Corallo <=