diff options
author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2017-09-30 10:57:52 -0700 |
---|---|---|
committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2017-09-30 16:28:00 -0700 |
commit | c59ddb212055609ec0c402708a2514ee6a30e836 (patch) | |
tree | f947e55c19617feba81f1115e926bcf6eaad7df7 /test | |
parent | 8b2ab5014b2c1641bb62efa63b9ee54b4c056b5a (diff) | |
download | emacs-c59ddb212055609ec0c402708a2514ee6a30e836.tar.gz |
Fix slot typecheck in eieio-persistent
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-slot-type-is-class-p):
An `or' form can specify multiple potential classes (or null) as
valid types for a slot, but previously only the final element of the
`or' was actually checked. Now returns all valid classes in the `or'
form.
(eieio-persistent-validate/fix-slot-value): Check if proposed value
matches any of the valid classes.
* test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
(eieio-test-multiple-class-slot): Test this behavior.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el | 22 |
1 files changed, 22 insertions, 0 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 e2cff3fbcaa..738711c9c84 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el @@ -195,6 +195,28 @@ persistent class.") (persist-test-save-and-compare persist-woss) (delete-file (oref persist-woss file)))) +;; A slot that can contain one of two different classes, to exercise +;; the `or' slot type. + +(defclass persistent-random-class () + ()) + +(defclass persistent-multiclass-slot (eieio-persistent) + ((slot1 :initarg :slot1 + :type (or persistent-random-class null persist-not-persistent)) + (slot2 :initarg :slot2 + :type (or persist-not-persistent persist-random-class null)))) + +(ert-deftest eieio-test-multiple-class-slot () + (let ((persist + (persistent-multiclass-slot "random string" + :slot1 (persistent-random-class) + :slot2 (persist-not-persistent) + :file (concat default-directory "test-ps5.pt")))) + (unwind-protect + (persist-test-save-and-compare persist) + (ignore-errors (delete-file (oref persist file)))))) + ;;; Slot with a list of Objects ;; ;; A slot that contains another object that isn't persistent |