emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4e8b50ec57b: * test/lisp/subr-tests.el (subr--safe-copy-tree): Ne


From: Alan Mackenzie
Subject: master 4e8b50ec57b: * test/lisp/subr-tests.el (subr--safe-copy-tree): New tests for safe-copy-tree
Date: Tue, 7 Mar 2023 12:39:59 -0500 (EST)

branch: master
commit 4e8b50ec57bc0d70bdb1279756eec679eb4eab0d
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    * test/lisp/subr-tests.el (subr--safe-copy-tree): New tests for 
safe-copy-tree
---
 test/lisp/subr-tests.el | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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."))
     (should (equal a-dedup '("a" "b" "a" "b" "c")))
     (should (eq a a-dedup))))
 
+(ert-deftest subr--safe-copy-tree ()
+  (should (null (safe-copy-tree nil)))
+  (let* ((foo '(1 2 (3 4))) (bar (safe-copy-tree foo)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should-not (eq (caddr bar) (caddr foo))))
+  (let* ((foo '#1=(a #1#)) (bar (safe-copy-tree foo)))
+    (should (eq (car bar) (car foo)))
+;    (should-not (proper-list-p bar))
+    (should (eq (caadr bar) (caadr foo)))
+    (should (eq (caadr bar) 'a)))
+  (let* ((foo [1 2 3 4]) (bar (safe-copy-tree foo)))
+    (should (eq bar foo)))
+  (let* ((foo [1 (2 3) 4]) (bar (safe-copy-tree foo t)))
+    (should-not (eq bar foo))
+    (should (equal bar foo))
+    (should-not (eq (aref bar 1) (aref foo 1))))
+  (let* ((foo [1 [2 3] 4]) (bar (safe-copy-tree foo t)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should-not (eq (aref bar 1) (aref foo 1))))
+  (let* ((foo (record 'foo 1 "two" 3)) (bar (safe-copy-tree foo t)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should (eq (aref bar 2) (aref foo 2)))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]