]> git.eshelyaron.com Git - emacs.git/commit
Fix cl-seq-tests.el
authorBasil L. Contovounesios <basil@contovou.net>
Sat, 25 Jan 2025 15:48:19 +0000 (16:48 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 14 Feb 2025 11:44:12 +0000 (12:44 +0100)
commit2e9253882d36e6a50ed8a2767cca7f861c8c3bcb
treec31c868d7b26133c894f0e62028db0f6f4424c10
parent091c592dd776dc014d9c7b071726c350b172c9fd
Fix cl-seq-tests.el

None of the tests using the macro cl-seq--with-side-effects were
being evaluated (since bug#24264), and other tests were not robust
against destructive operations or optimizations (since bug#24264 and
bug#75633).  For further discussion, see:
https://lists.gnu.org/r/emacs-devel/2025-02/msg00053.html

* test/lisp/emacs-lisp/cl-seq-tests.el: Fit first line within 80
columns.  Remove empty Commentary section.
(cl-union-test-00): Use bug#N reference in place of URL.
(cl-seq-test-bug24264): Ditto.  Use nconc in place of append.
(cl-seq--test-list, cl-seq--test-list2, cl-seq--with-side-effects):
Remove.
(cl-seq-tests--relet*): New convenience macro replacing the need for
cl-seq--with-side-effects.
(cl-seq-fill-test, cl-seq-replace-test, cl-seq-delete-test): Use
cl-seq-tests--relet* to actually evaluate tests.  Avoid mutating
quoted literals.
(cl-seq-nsubstitute-test): Ditto.  Actually call cl-nsubstitute, not
cl-substitute.  Avoid comparing mutated argument to itself; compare
to its original copy instead.  Avoid calling cl-position on list
that is being mutated in :if predicate; use original copy instead.
(cl-seq-remove-test, cl-remove-if-not-test, cl-delete-if-not-test)
(cl-delete-duplicates-test, cl-seq-remove-duplicates-test)
(cl-seq-substitute-test, cl-seq-substitute-if-test)
(cl-seq-position-test, cl-count-if-test, cl-count-if-not-test)
(cl-member-if-test, cl-member-if-not-test, cl-assoc-if-test)
(cl-assoc-if-not-test, cl-rassoc-if-test, cl-subsetp-test):
Simplify.
(cl-remove-if-test, cl-seq-substitute-if-not-test, cl-find-if-test)
(cl-find-if-not-test, cl-position-if-test, cl-member-test)
(cl-assoc-test, cl-rassoc-test): Quote function symbols, not
lambdas.
(cl-delete-if-test): Use cl-seq-tests--relet*.  Check result of
cl-delete-if to avoid relying on its side effects, and to pacify
byte-compiler warning.
(cl-seq-mismatch-test): Avoid 'easy to misread' hidden argument.
(cl-seq-search-test): Break long line.
(cl-sort-test, cl-stable-sort-test, cl-merge-test): Avoid mutating
quoted literals.
(cl-intersection-test): Avoid comparing eql-ity of string literals.
(cl-nintersection-test, cl-nset-difference-test)
(cl-nset-exclusive-or-test): Avoid mutating quoted literals.  Don't
compare initial and final values of arguments, since they may have
been mutated.
(cl-set-difference-test, cl-set-exclusive-or-test): Use fresh
arguments to check for absence of mutation.

(cherry picked from commit 52034675a2e774fb0f819603f3d3f293fdeb448b)
test/lisp/emacs-lisp/cl-seq-tests.el