diff options
Diffstat (limited to 'test/lisp/emacs-lisp/eieio-tests')
-rw-r--r-- | test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el | 10 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/eieio-tests/eieio-tests.el | 21 |
2 files changed, 26 insertions, 5 deletions
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el index 4feaebed452..4f13881dbd4 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el @@ -40,7 +40,7 @@ This is usually a symbol that starts with `:'." (car tuple) nil))) -(defun hash-equal (hash1 hash2) +(defun eieio-test--hash-equal (hash1 hash2) "Compare two hash tables to see whether they are equal." (and (= (hash-table-count hash1) (hash-table-count hash2)) @@ -78,7 +78,7 @@ This is usually a symbol that starts with `:'." (if initarg-p (unless (cond ((and (hash-table-p origvalue) (hash-table-p fromdiskvalue)) - (hash-equal origvalue fromdiskvalue)) + (eieio-test--hash-equal origvalue fromdiskvalue)) (t (equal origvalue fromdiskvalue))) (error "Slot %S Original Val %S != Persistent Val %S" oneslot origvalue fromdiskvalue)) @@ -87,7 +87,7 @@ This is usually a symbol that starts with `:'." (diskval fromdiskvalue)) (unless (cond ((and (hash-table-p origval) (hash-table-p diskval)) - (hash-equal origval diskval)) + (eieio-test--hash-equal origval diskval)) (t (equal origval diskval))) (error "Slot %S Persistent Val %S != Default Value %S" oneslot diskval origvalue)))))))) @@ -329,8 +329,8 @@ persistent class.") "container-" emacs-version ".eieio"))) (john (make-instance 'person :name "John")) (alexie (make-instance 'person :name "Alexie")) - (alst '(("first" (one two three)) - ("second" (four five six))))) + (alst (list (list "first" (list 'one 'two 'three)) + (list "second" (list 'four 'five 'six))))) (setf (slot-value thing 'alist) alst) (puthash "alst" alst (slot-value thing 'htab)) (aset (slot-value thing 'vec) 0 alst) diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el index c9993341f98..a0507afe833 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el @@ -1046,6 +1046,27 @@ Subclasses to override slot attributes.")) (should (eq (eieio-test--struct-a x) 1)) (should-error (setf (slot-value x 'c) 3) :type 'eieio-read-only))) +(defclass foo-bug-66938 (eieio-instance-inheritor) + ((x :initarg :x + :accessor ref-x + :reader get-x)) + "A class to test that delegation occurs under certain +circumstances when using an accessor function, as it would when +using the reader function.") + +(ert-deftest eieio-test-use-accessor-function-with-cloned-object () + "The class FOO-BUG-66938 is a subclass of +`eieio-instance-inheritor'. Therefore, given an instance OBJ1 of +FOO-BUG-66938, and a clone (OBJ2), OBJ2 should delegate to OBJ1 +when accessing an unbound slot. + +In particular, its behavior should be identical to that of the +reader function, when reading a slot." + (let* ((obj1 (foo-bug-66938 :x 4)) + (obj2 (clone obj1))) + (should (eql (ref-x obj2) 4)) + (should (eql (get-x obj2) (ref-x obj2))))) + (provide 'eieio-tests) ;;; eieio-tests.el ends here |