summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2023-05-13 13:36:50 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2023-05-13 14:31:00 +0200
commit63be4d11b58630251c70508267792d4a6d431fdd (patch)
tree890ac1c5e068dc751eb663916dd96ff9e4dd61ea
parent9f856e4cd095c24cf4e6cadbc04efaf533e59f37 (diff)
downloademacs-63be4d11b58630251c70508267792d4a6d431fdd.tar.gz
Don't mutate constants in tests
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): * test/lisp/emacs-lisp/cl-print-tests.el (cl-print-tests-ellipsis-circular): * test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el (eieio-test-persist-interior-lists): * test/lisp/textmodes/reftex-tests.el (reftex-all-used-citation-keys): * test/src/xdisp-tests.el (xdisp-tests--minibuffer-resizing): * test/src/fns-tests.el (test-vector-delete): Mutate created objects, not constants. * test/lisp/emacs-lisp/subr-x-tests.el (subr-x-test-add-display-text-property): Mutate a created string, and compare using `equal-including-properties` without which the test was rather meaningless. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test16-directory-files): Don't mutate.
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el2
-rw-r--r--test/lisp/emacs-lisp/cl-print-tests.el2
-rw-r--r--test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el4
-rw-r--r--test/lisp/emacs-lisp/subr-x-tests.el17
-rw-r--r--test/lisp/net/tramp-archive-tests.el4
-rw-r--r--test/lisp/textmodes/reftex-tests.el3
-rw-r--r--test/src/fns-tests.el2
-rw-r--r--test/src/xdisp-tests.el2
8 files changed, 19 insertions, 17 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index a9ec0b76ae8..a4bc8d542d4 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -535,7 +535,7 @@ collection clause."
(eval '(let ((l (list 1))) (cl-symbol-macrolet ((x 1)) (setq (car l) 0))) t))
;; Make sure `gv-synthetic-place' isn't macro-expanded before `setf' gets to
;; see its `gv-expander'.
- (should (equal (let ((l '(0)))
+ (should (equal (let ((l (list 0)))
(let ((cl (car l)))
(cl-symbol-macrolet
((p (gv-synthetic-place cl (lambda (v) `(setcar l ,v)))))
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el
index 7161035d75a..af94dae310c 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -90,7 +90,7 @@
(ert-deftest cl-print-tests-ellipsis-circular ()
"Ellipsis expansion works with circular objects."
(let ((wide-obj (list 0 1 2 3 4))
- (deep-obj `(0 (1 (2 (3 (4))))))
+ (deep-obj (list 0 (list 1 (list 2 (list 3 (list 4))))))
(print-length 4)
(print-level 3))
(setf (nth 4 wide-obj) wide-obj)
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
index 4feaebed452..4e5d2f36cf8 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
@@ -329,8 +329,8 @@ persistent class.")
"container-" emacs-version ".eieio")))
(john (make-instance 'person :name "John"))
(alexie (make-instance 'person :name "Alexie"))
- (alst '(("first" (one two three))
- ("second" (four five six)))))
+ (alst (list (list "first" (list 'one 'two 'three))
+ (list "second" (list 'four 'five 'six)))))
(setf (slot-value thing 'alist) alst)
(puthash "alst" alst (slot-value thing 'htab))
(aset (slot-value thing 'vec) 0 alst)
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el
index e4c270a114f..63d8fcd080c 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -709,14 +709,15 @@
[(raise 0.5) (height 2.0)]))
(should (equal (get-text-property 9 'display) '(raise 0.5))))
(with-temp-buffer
- (should (equal (let ((str "some useless string"))
- (add-display-text-property 4 8 'height 2.0 str)
- (add-display-text-property 2 12 'raise 0.5 str)
- str)
- #("some useless string"
- 2 4 (display (raise 0.5))
- 4 8 (display ((raise 0.5) (height 2.0)))
- 8 12 (display (raise 0.5)))))))
+ (should (equal-including-properties
+ (let ((str (copy-sequence "some useless string")))
+ (add-display-text-property 4 8 'height 2.0 str)
+ (add-display-text-property 2 12 'raise 0.5 str)
+ str)
+ #("some useless string"
+ 2 4 (display (raise 0.5))
+ 4 8 (display ((raise 0.5) (height 2.0)))
+ 8 12 (display (raise 0.5)))))))
(ert-deftest subr-x-named-let ()
(let ((funs ()))
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 2e2e313f35c..80ec67da8d2 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -587,11 +587,11 @@ This checks also `file-name-as-directory', `file-name-directory',
(mapcar (lambda (x) (concat tmp-name x)) files)))
(should (equal (directory-files
tmp-name nil directory-files-no-dot-files-regexp)
- (delete "." (delete ".." files))))
+ (remove "." (remove ".." files))))
(should (equal (directory-files
tmp-name 'full directory-files-no-dot-files-regexp)
(mapcar (lambda (x) (concat tmp-name x))
- (delete "." (delete ".." files))))))
+ (remove "." (remove ".." files))))))
;; Cleanup.
(tramp-archive-cleanup-hash))))
diff --git a/test/lisp/textmodes/reftex-tests.el b/test/lisp/textmodes/reftex-tests.el
index 5a137ba8a67..6aa12bc3b58 100644
--- a/test/lisp/textmodes/reftex-tests.el
+++ b/test/lisp/textmodes/reftex-tests.el
@@ -294,7 +294,8 @@ And this should be % \\cite{ignored}.
(find-file tex-file)
(setq keys (reftex-all-used-citation-keys))
(should (equal (sort keys #'string<)
- (sort '(;; Standard commands:
+ (sort (list
+ ;; Standard commands:
"cite:2022" "Cite:2022"
"parencite:2022" "Parencite:2022"
"footcite:2022" "footcitetext:2022"
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 2859123da80..79ae4393f40 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -1101,7 +1101,7 @@
(ert-deftest test-vector-delete ()
(let ((v1 (make-vector 1000 1)))
- (should (equal (delete t [nil t]) [nil]))
+ (should (equal (delete t (vector nil t)) [nil]))
(should (equal (delete 1 v1) (vector)))
(should (equal (delete 2 v1) v1))))
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el
index 52ed79b0f20..dfd38a9d4c1 100644
--- a/test/src/xdisp-tests.el
+++ b/test/src/xdisp-tests.el
@@ -40,7 +40,7 @@
(insert "hello")
(let ((ol (make-overlay (point) (point)))
(max-mini-window-height 1)
- (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh"))
+ (text (copy-sequence "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh")))
;; (save-excursion (insert text))
;; (sit-for 2)
;; (delete-region (point) (point-max))