diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-16 23:48:26 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-16 23:48:26 -0500 |
commit | d48c98cda83d2c74981c61a0b9d9b379c46217f4 (patch) | |
tree | 796b531601ab918a463a0a0b92283c849faf31b8 /test | |
parent | 24b7f77581c7eefe484db6cbbd661c04460c66aa (diff) | |
download | emacs-d48c98cda83d2c74981c61a0b9d9b379c46217f4.tar.gz |
Don't enforce :protection in EIEIO objects any more
* doc/misc/eieio.texi (Slot Options): Document :protection as unsupported.
* lisp/emacs-lisp/eieio-core.el (eieio--scoped-class-stack): Remove var.
(eieio--scoped-class): Remove function.
(eieio--with-scoped-class): Remove macro. Replace uses with `progn'.
(eieio--slot-name-index): Don't check the :protection anymore.
(eieio-initializing-object): Remove var.
(eieio-set-defaults): Don't let-bind eieio-initializing-object.
* lisp/emacs-lisp/eieio-generic.el (call-next-method): Don't bother checking
eieio--scoped-class any more.
* test/automated/eieio-test-methodinvoke.el (eieio-test-method-store):
Use an explicit arg instead of eieio--scoped-class. Update all callers.
* test/automated/eieio-tests.el (eieio-test-25-slot-tests)
(eieio-test-26-default-inheritance, eieio-test-28-slot-protection)
(eieio-test-30-slot-attribute-override)
(eieio-test-31-slot-attribute-override-class-allocation): Don't check
that we enforce :protection since we don't any more.
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 15 | ||||
-rw-r--r-- | test/automated/eieio-test-methodinvoke.el | 52 | ||||
-rw-r--r-- | test/automated/eieio-tests.el | 43 |
3 files changed, 62 insertions, 48 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index c40407f496b..2f5ff054917 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,7 +1,18 @@ 2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca> - * automated/eieio-test-methodinvoke.el (eieio-test-cl-generic-1): Reset - eieio-test--1. + * automated/eieio-tests.el (eieio-test-25-slot-tests) + (eieio-test-26-default-inheritance, eieio-test-28-slot-protection) + (eieio-test-30-slot-attribute-override) + (eieio-test-31-slot-attribute-override-class-allocation): Don't check + that we enforce :protection since we don't any more. + + * automated/eieio-test-methodinvoke.el (eieio-test-method-store): + Use an explicit arg instead of eieio--scoped-class. Update all callers. + +2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca> + + * automated/eieio-test-methodinvoke.el (eieio-test-cl-generic-1): + Reset eieio-test--1. * automated/cl-generic-tests.el (cl-generic-test-8-after/before): Rename from cl-generic-test-7-after/before. diff --git a/test/automated/eieio-test-methodinvoke.el b/test/automated/eieio-test-methodinvoke.el index 1c3d9c34708..b6d60b85815 100644 --- a/test/automated/eieio-test-methodinvoke.el +++ b/test/automated/eieio-test-methodinvoke.el @@ -58,11 +58,9 @@ (defvar eieio-test-method-order-list nil "List of symbols stored during method invocation.") -(defun eieio-test-method-store (keysym) +(defun eieio-test-method-store (&rest args) "Store current invocation class symbol in the invocation order list." - ;; FIXME: Don't depend on `eieio--scoped-class'! - (let* ((c (list keysym (eieio--class-symbol (eieio--scoped-class))))) - (push c eieio-test-method-order-list))) + (push args eieio-test-method-order-list)) (defun eieio-test-match (rightanswer) "Do a test match." @@ -86,36 +84,36 @@ (defclass eitest-B (eitest-B-base1 eitest-B-base2) ()) (defmethod eitest-F :BEFORE ((p eitest-B-base1)) - (eieio-test-method-store :BEFORE)) + (eieio-test-method-store :BEFORE 'eitest-B-base1)) (defmethod eitest-F :BEFORE ((p eitest-B-base2)) - (eieio-test-method-store :BEFORE)) + (eieio-test-method-store :BEFORE 'eitest-B-base2)) (defmethod eitest-F :BEFORE ((p eitest-B)) - (eieio-test-method-store :BEFORE)) + (eieio-test-method-store :BEFORE 'eitest-B)) (defmethod eitest-F ((p eitest-B)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'eitest-B) (call-next-method)) (defmethod eitest-F ((p eitest-B-base1)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'eitest-B-base1) (call-next-method)) (defmethod eitest-F ((p eitest-B-base2)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'eitest-B-base2) (when (next-method-p) (call-next-method)) ) (defmethod eitest-F :AFTER ((p eitest-B-base1)) - (eieio-test-method-store :AFTER)) + (eieio-test-method-store :AFTER 'eitest-B-base1)) (defmethod eitest-F :AFTER ((p eitest-B-base2)) - (eieio-test-method-store :AFTER)) + (eieio-test-method-store :AFTER 'eitest-B-base2)) (defmethod eitest-F :AFTER ((p eitest-B)) - (eieio-test-method-store :AFTER)) + (eieio-test-method-store :AFTER 'eitest-B)) (ert-deftest eieio-test-method-order-list-3 () (let ((eieio-test-method-order-list nil) @@ -150,15 +148,15 @@ ;;; Return value from :PRIMARY ;; (defmethod eitest-I :BEFORE ((a eitest-A)) - (eieio-test-method-store :BEFORE) + (eieio-test-method-store :BEFORE 'eitest-A) ":before") (defmethod eitest-I :PRIMARY ((a eitest-A)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'eitest-A) ":primary") (defmethod eitest-I :AFTER ((a eitest-A)) - (eieio-test-method-store :AFTER) + (eieio-test-method-store :AFTER 'eitest-A) ":after") (ert-deftest eieio-test-method-order-list-5 () @@ -177,17 +175,17 @@ ;; Just use the obsolete name once, to make sure it also works. (defmethod constructor :STATIC ((p C-base1) &rest args) - (eieio-test-method-store :STATIC) + (eieio-test-method-store :STATIC 'C-base1) (if (next-method-p) (call-next-method)) ) (defmethod eieio-constructor :STATIC ((p C-base2) &rest args) - (eieio-test-method-store :STATIC) + (eieio-test-method-store :STATIC 'C-base2) (if (next-method-p) (call-next-method)) ) (defmethod eieio-constructor :STATIC ((p C) &rest args) - (eieio-test-method-store :STATIC) + (eieio-test-method-store :STATIC 'C) (call-next-method) ) @@ -214,24 +212,24 @@ (defmethod eitest-F ((p D)) "D" - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'D) (call-next-method)) (defmethod eitest-F ((p D-base0)) "D-base0" - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'D-base0) ;; This should have no next ;; (when (next-method-p) (call-next-method)) ) (defmethod eitest-F ((p D-base1)) "D-base1" - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'D-base1) (call-next-method)) (defmethod eitest-F ((p D-base2)) "D-base2" - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'D-base2) (when (next-method-p) (call-next-method)) ) @@ -256,21 +254,21 @@ (defclass E (E-base1 E-base2) () :method-invocation-order :breadth-first) (defmethod eitest-F ((p E)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'E) (call-next-method)) (defmethod eitest-F ((p E-base0)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'E-base0) ;; This should have no next ;; (when (next-method-p) (call-next-method)) ) (defmethod eitest-F ((p E-base1)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'E-base1) (call-next-method)) (defmethod eitest-F ((p E-base2)) - (eieio-test-method-store :PRIMARY) + (eieio-test-method-store :PRIMARY 'E-base2) (when (next-method-p) (call-next-method)) ) diff --git a/test/automated/eieio-tests.el b/test/automated/eieio-tests.el index 0b1ff1fd93b..3a32da67ef9 100644 --- a/test/automated/eieio-tests.el +++ b/test/automated/eieio-tests.el @@ -563,7 +563,7 @@ METHOD is the method that was attempting to be called." (should (eq (oref eitest-t1 slot-1) 'moose)) (should (eq (oref eitest-t1 :moose) 'moose)) ;; Don't pass reference of private slot - (should-error (oref eitest-t1 slot-2) :type 'invalid-slot-name) + ;;PRIVATE (should-error (oref eitest-t1 slot-2) :type 'invalid-slot-name) ;; Check private slot accessor (should (string= (get-slot-2 eitest-t1) "penguin")) ;; Pass string instead of symbol @@ -583,7 +583,7 @@ METHOD is the method that was attempting to be called." (should (eq (oref eitest-t2 slot-1) 'moose)) (should (eq (oref eitest-t2 :moose) 'moose)) (should (string= (get-slot-2 eitest-t2) "linux")) - (should-error (oref eitest-t2 slot-2) :type 'invalid-slot-name) + ;;PRIVATE (should-error (oref eitest-t2 slot-2) :type 'invalid-slot-name) (should (string= (get-slot-2 eitest-t2) "linux")) (should-error (class-subc :moose "not a symbol") :type 'invalid-slot-type)) @@ -654,20 +654,23 @@ Do not override for `prot-2'." ;; Access public slots (oref eitest-p1 slot-1) (oref eitest-p2 slot-1) - ;; Accessing protected slot out of context must fail - (should-error (oref eitest-p1 slot-2) :type 'invalid-slot-name) + ;; Accessing protected slot out of context used to fail, but we dropped this + ;; feature, since it was underused and noone noticed that the check was + ;; incorrect (much too loose). + ;;PROTECTED (should-error (oref eitest-p1 slot-2) :type 'invalid-slot-name) ;; Access protected slot in method (prot1-slot-2 eitest-p1) ;; Protected slot in subclass method (prot1-slot-2 eitest-p2) ;; Protected slot from parent class method (prot0-slot-2 eitest-p1) - ;; Accessing private slot out of context must fail - (should-error (oref eitest-p1 slot-3) :type 'invalid-slot-name) + ;; Accessing private slot out of context used to fail, but we dropped this + ;; feature, since it was not used. + ;;PRIVATE (should-error (oref eitest-p1 slot-3) :type 'invalid-slot-name) ;; Access private slot in method (prot1-slot-3 eitest-p1) ;; Access private slot in subclass method must fail - (should-error (prot1-slot-3 eitest-p2) :type 'invalid-slot-name) + ;;PRIVATE (should-error (prot1-slot-3 eitest-p2) :type 'invalid-slot-name) ;; Access private slot by same class (prot1-slot-3-only eitest-p1) ;; Access private slot by subclass in sameclass method @@ -729,12 +732,13 @@ Subclasses to override slot attributes.") (ert-deftest eieio-test-30-slot-attribute-override () ;; Subclass should not override :protection slot attribute - (should-error - (eval - '(defclass slotattr-fail (slotattr-base) - ((protection :protection :public) - ) - "This class should throw an error."))) + ;;PROTECTION is gone. + ;;(should-error + ;; (eval + ;; '(defclass slotattr-fail (slotattr-base) + ;; ((protection :protection :public) + ;; ) + ;; "This class should throw an error."))) ;; Subclass should not override :type slot attribute (should-error @@ -782,12 +786,13 @@ Subclasses to override slot attributes.") (ert-deftest eieio-test-31-slot-attribute-override-class-allocation () ;; Same as test-30, but with class allocation - (should-error - (eval - '(defclass slotattr-fail (slotattr-class-base) - ((protection :protection :public) - ) - "This class should throw an error."))) + ;;PROTECTION is gone. + ;;(should-error + ;; (eval + ;; '(defclass slotattr-fail (slotattr-class-base) + ;; ((protection :protection :public) + ;; ) + ;; "This class should throw an error."))) (should-error (eval '(defclass slotattr-fail (slotattr-class-base) |