diff options
| author | Andrea Corallo | 2024-02-28 20:47:57 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2024-02-28 20:47:57 +0100 |
| commit | 1fbe56c32761efdc8d268df80a97a9102d00e109 (patch) | |
| tree | 8d8e76c8ae43c79ef9d76b0f97c12607567664b9 /test/src | |
| parent | 6de60f33ed5cc438e20400aee83e1e2032773811 (diff) | |
| parent | 05195e129fc933db32c9e08a155a94bfa4d75b54 (diff) | |
| download | emacs-1fbe56c32761efdc8d268df80a97a9102d00e109.tar.gz emacs-1fbe56c32761efdc8d268df80a97a9102d00e109.zip | |
Merge remote-tracking branch 'origin/master' into 'feature/type-hierarchy'
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/comp-resources/comp-test-funcs.el | 4 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 25 | ||||
| -rw-r--r-- | test/src/eval-tests.el | 37 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 10 | ||||
| -rw-r--r-- | test/src/minibuf-tests.el | 14 | ||||
| -rw-r--r-- | test/src/treesit-tests.el | 2 |
6 files changed, 64 insertions, 28 deletions
diff --git a/test/src/comp-resources/comp-test-funcs.el b/test/src/comp-resources/comp-test-funcs.el index 4cee084e211..dc4abf50767 100644 --- a/test/src/comp-resources/comp-test-funcs.el +++ b/test/src/comp-resources/comp-test-funcs.el | |||
| @@ -367,11 +367,11 @@ | |||
| 367 | (while (consp insn) | 367 | (while (consp insn) |
| 368 | (let ((newcar (car insn))) | 368 | (let ((newcar (car insn))) |
| 369 | (if (or (consp (car insn)) (comp-mvar-p (car insn))) | 369 | (if (or (consp (car insn)) (comp-mvar-p (car insn))) |
| 370 | (setf newcar (comp-copy-insn (car insn)))) | 370 | (setf newcar (comp--copy-insn (car insn)))) |
| 371 | (push newcar result)) | 371 | (push newcar result)) |
| 372 | (setf insn (cdr insn))) | 372 | (setf insn (cdr insn))) |
| 373 | (nconc (nreverse result) | 373 | (nconc (nreverse result) |
| 374 | (if (comp-mvar-p insn) (comp-copy-insn insn) insn))) | 374 | (if (comp-mvar-p insn) (comp--copy-insn insn) insn))) |
| 375 | (if (comp-mvar-p insn) | 375 | (if (comp-mvar-p insn) |
| 376 | (copy-comp-mvar insn) | 376 | (copy-comp-mvar insn) |
| 377 | insn))) | 377 | insn))) |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 8bfe939fb23..67d632823b2 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) |
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index e1c90feb09a..187dc2f34d5 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -282,26 +282,39 @@ expressions works for identifiers starting with period." | |||
| 282 | (should-error (defvaralias 'eval-tests--my-c 'eval-tests--my-d) | 282 | (should-error (defvaralias 'eval-tests--my-c 'eval-tests--my-d) |
| 283 | :type 'cyclic-variable-indirection)) | 283 | :type 'cyclic-variable-indirection)) |
| 284 | 284 | ||
| 285 | (defvar eval-tests/global-var 'value) | 285 | (defvar eval-tests/global-var 'global-value) |
| 286 | (defvar-local eval-tests/buffer-local-var 'value) | 286 | (defvar-local eval-tests/buffer-local-var 'default-value) |
| 287 | (ert-deftest eval-tests/default-value () | 287 | (ert-deftest eval-tests/default-value () |
| 288 | ;; `let' overrides the default value for global variables. | 288 | ;; `let' overrides the default value for global variables. |
| 289 | (should (default-boundp 'eval-tests/global-var)) | 289 | (should (default-boundp 'eval-tests/global-var)) |
| 290 | (should (eq 'value (default-value 'eval-tests/global-var))) | 290 | (should (eq 'global-value (default-value 'eval-tests/global-var))) |
| 291 | (should (eq 'value eval-tests/global-var)) | 291 | (should (eq 'global-value eval-tests/global-var)) |
| 292 | (let ((eval-tests/global-var 'bar)) | 292 | (let ((eval-tests/global-var 'let-value)) |
| 293 | (should (eq 'bar (default-value 'eval-tests/global-var))) | 293 | (should (eq 'let-value (default-value 'eval-tests/global-var))) |
| 294 | (should (eq 'bar eval-tests/global-var))) | 294 | (should (eq 'let-value eval-tests/global-var))) |
| 295 | ;; `let' overrides the default value everywhere, but leaves | 295 | ;; `let' overrides the default value everywhere, but leaves |
| 296 | ;; buffer-local values unchanged in current buffer and in the | 296 | ;; buffer-local values unchanged in current buffer and in the |
| 297 | ;; buffers where there is no explicitly set buffer-local value. | 297 | ;; buffers where there is no explicitly set buffer-local value. |
| 298 | (should (default-boundp 'eval-tests/buffer-local-var)) | 298 | (should (default-boundp 'eval-tests/buffer-local-var)) |
| 299 | (should (eq 'value (default-value 'eval-tests/buffer-local-var))) | 299 | (should (eq 'default-value (default-value 'eval-tests/buffer-local-var))) |
| 300 | (should (eq 'value eval-tests/buffer-local-var)) | 300 | (should (eq 'default-value eval-tests/buffer-local-var)) |
| 301 | (with-temp-buffer | 301 | (with-temp-buffer |
| 302 | (let ((eval-tests/buffer-local-var 'bar)) | 302 | (let ((eval-tests/buffer-local-var 'let-value)) |
| 303 | (should (eq 'bar (default-value 'eval-tests/buffer-local-var))) | 303 | (should (eq 'let-value (default-value 'eval-tests/buffer-local-var))) |
| 304 | (should (eq 'bar eval-tests/buffer-local-var))))) | 304 | (should (eq 'let-value eval-tests/buffer-local-var)))) |
| 305 | ;; When current buffer has explicit buffer-local binding, `let' does | ||
| 306 | ;; not alter the default binding. | ||
| 307 | (with-temp-buffer | ||
| 308 | (setq-local eval-tests/buffer-local-var 'local-value) | ||
| 309 | (let ((eval-tests/buffer-local-var 'let-value)) | ||
| 310 | ;; Let in a buffer with local binding does not change the | ||
| 311 | ;; default value for variable. | ||
| 312 | (should (eq 'default-value (default-value 'eval-tests/buffer-local-var))) | ||
| 313 | (should (eq 'let-value eval-tests/buffer-local-var)) | ||
| 314 | (with-temp-buffer | ||
| 315 | ;; We are in a new buffer - `eval-tests/buffer-local-var' has its global default value. | ||
| 316 | (should (eq 'default-value (default-value 'eval-tests/buffer-local-var))) | ||
| 317 | (should (eq 'default-value eval-tests/buffer-local-var)))))) | ||
| 305 | 318 | ||
| 306 | (ert-deftest eval-tests--handler-bind () | 319 | (ert-deftest eval-tests--handler-bind () |
| 307 | ;; A `handler-bind' has no effect if no error is signaled. | 320 | ;; A `handler-bind' has no effect if no error is signaled. |
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 3893b8b0320..7437c07f156 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -1097,6 +1097,16 @@ | |||
| 1097 | (should (= (sxhash-equal (record 'a (make-string 10 ?a))) | 1097 | (should (= (sxhash-equal (record 'a (make-string 10 ?a))) |
| 1098 | (sxhash-equal (record 'a (make-string 10 ?a)))))) | 1098 | (sxhash-equal (record 'a (make-string 10 ?a)))))) |
| 1099 | 1099 | ||
| 1100 | (ert-deftest fns--define-hash-table-test () | ||
| 1101 | ;; Check that we can have two differently-named tests using the | ||
| 1102 | ;; same functions (bug#68668). | ||
| 1103 | (define-hash-table-test 'fns-tests--1 'my-cmp 'my-hash) | ||
| 1104 | (define-hash-table-test 'fns-tests--2 'my-cmp 'my-hash) | ||
| 1105 | (let ((h1 (make-hash-table :test 'fns-tests--1)) | ||
| 1106 | (h2 (make-hash-table :test 'fns-tests--2))) | ||
| 1107 | (should (eq (hash-table-test h1) 'fns-tests--1)) | ||
| 1108 | (should (eq (hash-table-test h2) 'fns-tests--2)))) | ||
| 1109 | |||
| 1100 | (ert-deftest test-secure-hash () | 1110 | (ert-deftest test-secure-hash () |
| 1101 | (should (equal (secure-hash 'md5 "foobar") | 1111 | (should (equal (secure-hash 'md5 "foobar") |
| 1102 | "3858f62230ac3c915f300c664312c63f")) | 1112 | "3858f62230ac3c915f300c664312c63f")) |
diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el index 14d160df25c..99d522d1856 100644 --- a/test/src/minibuf-tests.el +++ b/test/src/minibuf-tests.el | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | (let ((num 0)) | 34 | (let ((num 0)) |
| 35 | (mapcar (lambda (str) (cons str (cl-incf num))) list))) | 35 | (mapcar (lambda (str) (cons str (cl-incf num))) list))) |
| 36 | (defun minibuf-tests--strings-to-obarray (list) | 36 | (defun minibuf-tests--strings-to-obarray (list) |
| 37 | (let ((ob (make-vector 7 0))) | 37 | (let ((ob (obarray-make 7))) |
| 38 | (mapc (lambda (str) (intern str ob)) list) | 38 | (mapc (lambda (str) (intern str ob)) list) |
| 39 | ob)) | 39 | ob)) |
| 40 | (defun minibuf-tests--strings-to-string-hashtable (list) | 40 | (defun minibuf-tests--strings-to-string-hashtable (list) |
| @@ -61,6 +61,9 @@ | |||
| 61 | 61 | ||
| 62 | ;;; Testing functions that are agnostic to type of COLLECTION. | 62 | ;;; Testing functions that are agnostic to type of COLLECTION. |
| 63 | 63 | ||
| 64 | (defun minibuf-tests--set-equal (a b) | ||
| 65 | (null (cl-set-exclusive-or a b :test #'equal))) | ||
| 66 | |||
| 64 | (defun minibuf-tests--try-completion (xform-collection) | 67 | (defun minibuf-tests--try-completion (xform-collection) |
| 65 | (let* ((abcdef (funcall xform-collection '("abc" "def"))) | 68 | (let* ((abcdef (funcall xform-collection '("abc" "def"))) |
| 66 | (+abba (funcall xform-collection '("abc" "abba" "def")))) | 69 | (+abba (funcall xform-collection '("abc" "abba" "def")))) |
| @@ -101,7 +104,8 @@ | |||
| 101 | (let* ((abcdef (funcall xform-collection '("abc" "def"))) | 104 | (let* ((abcdef (funcall xform-collection '("abc" "def"))) |
| 102 | (+abba (funcall xform-collection '("abc" "abba" "def")))) | 105 | (+abba (funcall xform-collection '("abc" "abba" "def")))) |
| 103 | (should (equal (all-completions "a" abcdef) '("abc"))) | 106 | (should (equal (all-completions "a" abcdef) '("abc"))) |
| 104 | (should (equal (all-completions "a" +abba) '("abc" "abba"))) | 107 | (should (minibuf-tests--set-equal (all-completions "a" +abba) |
| 108 | '("abc" "abba"))) | ||
| 105 | (should (equal (all-completions "abc" +abba) '("abc"))) | 109 | (should (equal (all-completions "abc" +abba) '("abc"))) |
| 106 | (should (equal (all-completions "abcd" +abba) nil)))) | 110 | (should (equal (all-completions "abcd" +abba) nil)))) |
| 107 | 111 | ||
| @@ -111,7 +115,8 @@ | |||
| 111 | (+abba (funcall xform-collection '("abc" "abba" "def"))) | 115 | (+abba (funcall xform-collection '("abc" "abba" "def"))) |
| 112 | (+abba-member (funcall collection-member +abba))) | 116 | (+abba-member (funcall collection-member +abba))) |
| 113 | (should (equal (all-completions "a" abcdef abcdef-member) '("abc"))) | 117 | (should (equal (all-completions "a" abcdef abcdef-member) '("abc"))) |
| 114 | (should (equal (all-completions "a" +abba +abba-member) '("abc" "abba"))) | 118 | (should (minibuf-tests--set-equal (all-completions "a" +abba +abba-member) |
| 119 | '("abc" "abba"))) | ||
| 115 | (should (equal (all-completions "abc" +abba +abba-member) '("abc"))) | 120 | (should (equal (all-completions "abc" +abba +abba-member) '("abc"))) |
| 116 | (should (equal (all-completions "abcd" +abba +abba-member) nil)) | 121 | (should (equal (all-completions "abcd" +abba +abba-member) nil)) |
| 117 | (should-not (all-completions "a" abcdef #'ignore)) | 122 | (should-not (all-completions "a" abcdef #'ignore)) |
| @@ -124,7 +129,8 @@ | |||
| 124 | (+abba (funcall xform-collection '("abc" "abba" "def")))) | 129 | (+abba (funcall xform-collection '("abc" "abba" "def")))) |
| 125 | (let ((completion-regexp-list '("."))) | 130 | (let ((completion-regexp-list '("."))) |
| 126 | (should (equal (all-completions "a" abcdef) '("abc"))) | 131 | (should (equal (all-completions "a" abcdef) '("abc"))) |
| 127 | (should (equal (all-completions "a" +abba) '("abc" "abba"))) | 132 | (should (minibuf-tests--set-equal (all-completions "a" +abba) |
| 133 | '("abc" "abba"))) | ||
| 128 | (should (equal (all-completions "abc" +abba) '("abc"))) | 134 | (should (equal (all-completions "abc" +abba) '("abc"))) |
| 129 | (should (equal (all-completions "abcd" +abba) nil))) | 135 | (should (equal (all-completions "abcd" +abba) nil))) |
| 130 | (let ((completion-regexp-list '("X"))) | 136 | (let ((completion-regexp-list '("X"))) |
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index a89bf1298c0..bdc9630c783 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el | |||
| @@ -254,7 +254,7 @@ | |||
| 254 | (should (eq nil (treesit-node-text | 254 | (should (eq nil (treesit-node-text |
| 255 | (treesit-search-subtree | 255 | (treesit-search-subtree |
| 256 | subarray "\\[")))) | 256 | subarray "\\[")))) |
| 257 | ;; If ALL=nil, searching for number should still find the | 257 | ;; If ALL=t, searching for number should still find the |
| 258 | ;; numbers. | 258 | ;; numbers. |
| 259 | (should (equal "1" (treesit-node-text | 259 | (should (equal "1" (treesit-node-text |
| 260 | (treesit-search-subtree | 260 | (treesit-search-subtree |