diff options
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/data-tests.el | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index ad3b2071254..9d76c58224d 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -838,4 +838,41 @@ comparing the subr with a much slower Lisp implementation." | |||
| 838 | (dolist (sym (list nil t 'xyzzy (make-symbol ""))) | 838 | (dolist (sym (list nil t 'xyzzy (make-symbol ""))) |
| 839 | (should (eq sym (bare-symbol (position-symbol sym 0))))))) | 839 | (should (eq sym (bare-symbol (position-symbol sym 0))))))) |
| 840 | 840 | ||
| 841 | (require 'cl-extra) ;For `cl--class-children'. | ||
| 842 | |||
| 843 | (ert-deftest data-tests--cl-type-of () | ||
| 844 | ;; Make sure that `cl-type-of' returns the most precise type. | ||
| 845 | ;; Note: This doesn't work for list/vector structs since those types | ||
| 846 | ;; are too difficult/unreliable to detect (so `cl-type-of' only says | ||
| 847 | ;; it's a `cons' or a `vector'). | ||
| 848 | (dolist (val (list -2 10 (expt 2 128) nil t 'car | ||
| 849 | (symbol-function 'car) | ||
| 850 | (symbol-function 'progn) | ||
| 851 | (position-symbol 'car 7))) | ||
| 852 | (let* ((type (cl-type-of val)) | ||
| 853 | (class (cl-find-class type)) | ||
| 854 | (alltypes (cl--class-allparents class)) | ||
| 855 | ;; FIXME: Our type DAG is affected by `symbols-with-pos-enabled'. | ||
| 856 | ;; (e.g. `symbolp' returns nil on a sympos if that var is nil). | ||
| 857 | (symbols-with-pos-enabled t)) | ||
| 858 | (dolist (parent alltypes) | ||
| 859 | (should (cl-typep val parent)) | ||
| 860 | (dolist (subtype (cl--class-children (cl-find-class parent))) | ||
| 861 | (unless (memq subtype alltypes) | ||
| 862 | (unless (memq subtype | ||
| 863 | ;; FIXME: Some types don't have any associated | ||
| 864 | ;; predicate, | ||
| 865 | '( font-spec font-entity font-object | ||
| 866 | finalizer condvar terminal | ||
| 867 | native-comp-unit interpreted-function | ||
| 868 | tree-sitter-compiled-query | ||
| 869 | tree-sitter-node tree-sitter-parser | ||
| 870 | ;; `functionp' also matches things of type | ||
| 871 | ;; `symbol' and `cons'. | ||
| 872 | ;; FIXME: `subr-primitive-p' also matches | ||
| 873 | ;; special-forms. | ||
| 874 | function subr-primitive)) | ||
| 875 | (should-not (cl-typep val subtype))))))))) | ||
| 876 | |||
| 877 | |||
| 841 | ;;; data-tests.el ends here | 878 | ;;; data-tests.el ends here |