* test/lisp/subr-tests.el (subr--safe-copy-tree): New tests for safe-copy-tree
This commit is contained in:
parent
29f65920fb
commit
4e8b50ec57
1 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue