aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2023-03-07 17:38:20 +0000
committerAlan Mackenzie2023-03-07 17:38:20 +0000
commit4e8b50ec57bc0d70bdb1279756eec679eb4eab0d (patch)
tree91c8b16f6c22756855643a25be5116b6e68a8978
parent29f65920fb49588dd4fa29b33e7ed024afc6ffb6 (diff)
downloademacs-4e8b50ec57bc0d70bdb1279756eec679eb4eab0d.tar.gz
emacs-4e8b50ec57bc0d70bdb1279756eec679eb4eab0d.zip
* test/lisp/subr-tests.el (subr--safe-copy-tree): New tests for safe-copy-tree
-rw-r--r--test/lisp/subr-tests.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 050ee22ac18..37fe09c1716 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1205,5 +1205,31 @@ final or penultimate step during initialization."))
1205 (should (equal a-dedup '("a" "b" "a" "b" "c"))) 1205 (should (equal a-dedup '("a" "b" "a" "b" "c")))
1206 (should (eq a a-dedup)))) 1206 (should (eq a a-dedup))))
1207 1207
1208(ert-deftest subr--safe-copy-tree ()
1209 (should (null (safe-copy-tree nil)))
1210 (let* ((foo '(1 2 (3 4))) (bar (safe-copy-tree foo)))
1211 (should (equal bar foo))
1212 (should-not (eq bar foo))
1213 (should-not (eq (caddr bar) (caddr foo))))
1214 (let* ((foo '#1=(a #1#)) (bar (safe-copy-tree foo)))
1215 (should (eq (car bar) (car foo)))
1216; (should-not (proper-list-p bar))
1217 (should (eq (caadr bar) (caadr foo)))
1218 (should (eq (caadr bar) 'a)))
1219 (let* ((foo [1 2 3 4]) (bar (safe-copy-tree foo)))
1220 (should (eq bar foo)))
1221 (let* ((foo [1 (2 3) 4]) (bar (safe-copy-tree foo t)))
1222 (should-not (eq bar foo))
1223 (should (equal bar foo))
1224 (should-not (eq (aref bar 1) (aref foo 1))))
1225 (let* ((foo [1 [2 3] 4]) (bar (safe-copy-tree foo t)))
1226 (should (equal bar foo))
1227 (should-not (eq bar foo))
1228 (should-not (eq (aref bar 1) (aref foo 1))))
1229 (let* ((foo (record 'foo 1 "two" 3)) (bar (safe-copy-tree foo t)))
1230 (should (equal bar foo))
1231 (should-not (eq bar foo))
1232 (should (eq (aref bar 2) (aref foo 2)))))
1233
1208(provide 'subr-tests) 1234(provide 'subr-tests)
1209;;; subr-tests.el ends here 1235;;; subr-tests.el ends here