aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2019-05-27 19:05:56 -0400
committerNoam Postavsky2019-05-30 18:46:07 -0400
commit5f01af6c8e0f7355f7a99a80ff32369071f65eda (patch)
treef65280a7140425f0db5ad19782c699a0def2bed5 /test
parent4b24b0185d910d756e85ecdc30f49c414577050e (diff)
downloademacs-5f01af6c8e0f7355f7a99a80ff32369071f65eda.tar.gz
emacs-5f01af6c8e0f7355f7a99a80ff32369071f65eda.zip
Use plain symbols for eieio type descriptors (Bug#29220)
Since Emacs 26, eieio objects use a class record (with circular references) as the type descriptor of the object record. This causes problems when reading back an object from a string, because the class record is not `eq' to the canonical one (which means that read objects don't satisfy the foo-p predicate). * lisp/emacs-lisp/eieio.el (make-instance): As a (partial) fix, set the record's type descriptor to a plain symbol for the type descriptor when eieio-backward-compatibility is non-nil (the default). * lisp/emacs-lisp/eieio-core.el (eieio--object-class): Call eieio--class-object on the type tag when eieio-backward-compatibility is non-nil. (eieio-object-p): Use eieio--object-class instead of eieio--object-class-tag. * test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el (eieio-test-persist-hash-and-vector) (eieio-test-persist-interior-lists): Make into functions. (eieio-persist-hash-and-vector-backward-compatibility) (eieio-persist-hash-and-vector-no-backward-compatibility) (eieio-test-persist-interior-lists-backward-compatibility) (eieio-test-persist-interior-lists-no-backward-compatibility): New tests which call them, eieio-backward-compatibility let-bound.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el28
1 files changed, 22 insertions, 6 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 dfaa031844f..b87914c75e7 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
@@ -277,7 +277,7 @@ persistent class.")
277 :type vector 277 :type vector
278 :initarg :random-vector))) 278 :initarg :random-vector)))
279 279
280(ert-deftest eieio-test-persist-hash-and-vector () 280(defun eieio-test-persist-hash-and-vector ()
281 (let* ((jane (make-instance 'person :name "Jane")) 281 (let* ((jane (make-instance 'person :name "Jane"))
282 (bob (make-instance 'person :name "Bob")) 282 (bob (make-instance 'person :name "Bob"))
283 (hans (make-instance 'person :name "Hans")) 283 (hans (make-instance 'person :name "Hans"))
@@ -297,10 +297,18 @@ persistent class.")
297 (aset (car (slot-value class 'janitors)) 1 hans) 297 (aset (car (slot-value class 'janitors)) 1 hans)
298 (aset (nth 1 (slot-value class 'janitors)) 1 dierdre) 298 (aset (nth 1 (slot-value class 'janitors)) 1 dierdre)
299 (unwind-protect 299 (unwind-protect
300 ;; FIXME: This should not error. 300 (persist-test-save-and-compare class)
301 (should-error (persist-test-save-and-compare class))
302 (delete-file (oref class file))))) 301 (delete-file (oref class file)))))
303 302
303(ert-deftest eieio-persist-hash-and-vector-backward-compatibility ()
304 (let ((eieio-backward-compatibility t)) ; The default.
305 (eieio-test-persist-hash-and-vector)))
306
307(ert-deftest eieio-persist-hash-and-vector-no-backward-compatibility ()
308 :expected-result :failed ;; Bug#29220.
309 (let ((eieio-backward-compatibility nil))
310 (eieio-test-persist-hash-and-vector)))
311
304;; Extra quotation of lists inside other objects (Gnus registry), also 312;; Extra quotation of lists inside other objects (Gnus registry), also
305;; bug#29220. 313;; bug#29220.
306 314
@@ -315,7 +323,7 @@ persistent class.")
315 :initarg :htab 323 :initarg :htab
316 :type hash-table))) 324 :type hash-table)))
317 325
318(ert-deftest eieio-test-persist-interior-lists () 326(defun eieio-test-persist-interior-lists ()
319 (let* ((thing (make-instance 327 (let* ((thing (make-instance
320 'eieio-container 328 'eieio-container
321 :vec [nil] 329 :vec [nil]
@@ -335,8 +343,16 @@ persistent class.")
335 (setf (nth 2 (cadar alst)) john 343 (setf (nth 2 (cadar alst)) john
336 (nth 2 (cadadr alst)) alexie) 344 (nth 2 (cadadr alst)) alexie)
337 (unwind-protect 345 (unwind-protect
338 ;; FIXME: Should not error. 346 (persist-test-save-and-compare thing)
339 (should-error (persist-test-save-and-compare thing))
340 (delete-file (slot-value thing 'file))))) 347 (delete-file (slot-value thing 'file)))))
341 348
349(ert-deftest eieio-test-persist-interior-lists-backward-compatibility ()
350 (let ((eieio-backward-compatibility t)) ; The default.
351 (eieio-test-persist-interior-lists)))
352
353(ert-deftest eieio-test-persist-interior-lists-no-backward-compatibility ()
354 :expected-result :failed ;; Bug#29220.
355 (let ((eieio-backward-compatibility nil))
356 (eieio-test-persist-interior-lists)))
357
342;;; eieio-test-persist.el ends here 358;;; eieio-test-persist.el ends here