aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorAndrea Corallo2024-01-29 21:18:12 +0100
committerAndrea Corallo2024-01-29 21:24:38 +0100
commitcfc1779f4676b1be3ff34abc913e97a1b2a7de37 (patch)
tree964d48a5ce6657ed96c13eaf3e7162357cc097cf /test/src
parent98c906e5be2a3f5a14ff0172fdab38507b7746e3 (diff)
downloademacs-cfc1779f4676b1be3ff34abc913e97a1b2a7de37.tar.gz
emacs-cfc1779f4676b1be3ff34abc913e97a1b2a7de37.zip
* 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.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/comp-tests.el25
1 files 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."
904 (should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f))) 904 (should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f)))
905 (should (= (comp-tests-fw-prop-1-f) 6)))) 905 (should (= (comp-tests-fw-prop-1-f) 6))))
906 906
907(defun comp-tests--type-lists-equal (l1 l2)
908 (and (= (length l1) (length l2))
909 (cl-every #'comp-tests--types-equal l1 l2)))
910
907(defun comp-tests--types-equal (t1 t2) 911(defun comp-tests--types-equal (t1 t2)
908 "Whether the types T1 and T2 are equal." 912 "Whether the types T1 and T2 are equal."
909 (or (equal t1 t2) ; optimization for the common case 913 (or (equal t1 t2) ; for atoms, and optimization for the common case
910 (and (consp t1) (consp t2) 914 (and (consp t1) (consp t2)
911 (eq (car t1) (car t2)) 915 (eq (car t1) (car t2))
912 (if (memq (car t1) '(and or member)) 916 (cond ((memq (car t1) '(and or member))
913 (null (cl-set-exclusive-or (cdr t1) (cdr t2) 917 ;; Order or duplicates don't matter.
914 :test #'comp-tests--types-equal)) 918 (null (cl-set-exclusive-or (cdr t1) (cdr t2)
915 (and (= (length t1) (length t2)) 919 :test #'comp-tests--types-equal)))
916 (cl-every #'comp-tests--types-equal (cdr t1) (cdr t2))))))) 920 ((eq (car t1) 'function)
921 (and (comp-tests--type-lists-equal (nth 1 t1) (nth 1 t2))
922 (comp-tests--types-equal (nth 2 t1) (nth 2 t2))))
923 (t (comp-tests--type-lists-equal (cdr t1) (cdr t2)))))))
917 924
918(defun comp-tests-check-ret-type-spec (func-form ret-type) 925(defun comp-tests-check-ret-type-spec (func-form ret-type)
919 (let ((lexical-binding t) 926 (let ((lexical-binding t)