aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorJoseph Turner2023-05-14 21:02:15 -0700
committerEli Zaretskii2023-05-19 09:00:27 +0300
commit3a1285caba9cd25abaddbc541e3217e2559d79ab (patch)
tree5cfae8c27c61e780926d22fe1bb025ce9268ddf5 /test/lisp
parent8c9377b6c4e907e65712fbf0ba0cf90f51da5ef6 (diff)
downloademacs-3a1285caba9cd25abaddbc541e3217e2559d79ab.tar.gz
emacs-3a1285caba9cd25abaddbc541e3217e2559d79ab.zip
Make 'copy-tree' work with records
* doc/lispref/lists.texi (Building Cons Cells and Lists): Document new behavior of 'copy-tree'. * doc/lispref/records.texi (Record Functions): Cross-reference to lists.texi. * etc/NEWS: Mention change. (Bug#63509) * lisp/emacs-lisp/shortdoc.el: Add 'copy-tree' example to vector group. * lisp/subr.el (copy-tree): Recurse into records as well as vectors when optional second argument is non-nil. Rename second argument from VECP to VECTOR-LIKE-P. * test/lisp/subr-tests.el: Test new behavior.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/subr-tests.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 8f46c2af136..4ebb68556be 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1206,5 +1206,36 @@ final or penultimate step during initialization."))
1206 (should (equal a-dedup '("a" "b" "a" "b" "c"))) 1206 (should (equal a-dedup '("a" "b" "a" "b" "c")))
1207 (should (eq a a-dedup)))) 1207 (should (eq a a-dedup))))
1208 1208
1209(ert-deftest subr--copy-tree ()
1210 (should (eq (copy-tree nil) nil))
1211 (let* ((a (list (list "a") "b" (list "c") "g"))
1212 (copy1 (copy-tree a))
1213 (copy2 (copy-tree a t)))
1214 (should (equal a copy1))
1215 (should (equal a copy2))
1216 (should-not (eq a copy1))
1217 (should-not (eq a copy2)))
1218 (let* ((a (list (list "a") "b" (list "c" (record 'foo "d")) (list ["e" "f"]) "g"))
1219 (copy1 (copy-tree a))
1220 (copy2 (copy-tree a t)))
1221 (should (equal a copy1))
1222 (should (equal a copy2))
1223 (should-not (eq a copy1))
1224 (should-not (eq a copy2)))
1225 (let* ((a (record 'foo "a" (record 'bar "b")))
1226 (copy1 (copy-tree a))
1227 (copy2 (copy-tree a t)))
1228 (should (equal a copy1))
1229 (should (equal a copy2))
1230 (should (eq a copy1))
1231 (should-not (eq a copy2)))
1232 (let* ((a ["a" "b" ["c" ["d"]]])
1233 (copy1 (copy-tree a))
1234 (copy2 (copy-tree a t)))
1235 (should (equal a copy1))
1236 (should (equal a copy2))
1237 (should (eq a copy1))
1238 (should-not (eq a copy2))))
1239
1209(provide 'subr-tests) 1240(provide 'subr-tests)
1210;;; subr-tests.el ends here 1241;;; subr-tests.el ends here