summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/cl-print-tests.el10
-rw-r--r--test/src/alloc-tests.el20
2 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el
index 04ddfeeca8a..772601fe87d 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -37,4 +37,14 @@
(should (string-match "\\`#f(compiled-function (x) .*\n\n.*)\\'"
(cl-prin1-to-string (symbol-function #'caar))))))
+(ert-deftest cl-print-tests-2 ()
+ (let ((x (record 'foo 1 2 3)))
+ (should (equal
+ x
+ (car (read-from-string (with-output-to-string (prin1 x))))))
+ (let ((print-circle t))
+ (should (string-match
+ "\\`(#1=#s(foo 1 2 3) #1#)\\'"
+ (cl-prin1-to-string (list x x)))))))
+
;;; cl-print-tests.el ends here.
diff --git a/test/src/alloc-tests.el b/test/src/alloc-tests.el
index af4ad6c6355..8b4ef8ce7d2 100644
--- a/test/src/alloc-tests.el
+++ b/test/src/alloc-tests.el
@@ -31,3 +31,23 @@
(ert-deftest finalizer-object-type ()
(should (equal (type-of (make-finalizer nil)) 'finalizer)))
+
+(ert-deftest record-1 ()
+ (let ((x (record 'foo 1 2 3)))
+ (should (recordp x))
+ (should (eq (type-of x) 'foo))
+ (should (eq (aref x 0) 'foo))
+ (should (eql (aref x 3) 3))
+ (should (eql (length x) 4))))
+
+(ert-deftest record-2 ()
+ (let ((x (make-record 'bar 1 0)))
+ (should (eql (length x) 2))
+ (should (eql (aref x 1) 0))))
+
+(ert-deftest record-3 ()
+ (let* ((x (record 'foo 1 2 3))
+ (y (copy-record x)))
+ (should-not (eq x y))
+ (dotimes (i 4)
+ (should (eql (aref x i) (aref y i))))))