(defun eudc--plist-member (plist prop &optional predicate)
"Like `plist-member', but signal on invalid PLIST."
- ;; Could also use `plistp', but that would change the error.
- (or (zerop (% (length plist) 2))
- (error "Malformed plist"))
+ (or (plistp plist)
+ (signal 'wrong-type-argument `(plistp ,plist)))
(plist-member plist prop predicate))
(defun eudc-plist-member (plist prop)
(dolist (obj '(a (a . a) (a a . a)))
(should-error (eudc--plist-member obj nil) :type 'wrong-type-argument))
(dolist (plist '((nil) (a) (a a a)))
- (dolist (key '(nil a))
- (should (equal (should-error (eudc--plist-member plist key))
- '(error "Malformed plist")))))
+ (let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
+ (dolist (key '(nil a))
+ (should (equal err (should-error (eudc--plist-member plist key)))))))
(let ((-nil (string ?n ?i ?l))
(-a (string ?a)))
(should-not (eudc--plist-member () nil))
(dolist (obj '(a (a . a) (a a . a)))
(should-error (eudc-plist-member obj nil) :type 'wrong-type-argument))
(dolist (plist '((nil) (a) (a a a)))
- (dolist (key '(nil a))
- (should (equal (should-error (eudc-plist-member plist key))
- '(error "Malformed plist")))))
+ (let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
+ (dolist (key '(nil a))
+ (should (equal err (should-error (eudc-plist-member plist key)))))))
(let ((-nil (string ?n ?i ?l))
(-a (string ?a)))
(should-not (eudc-plist-member () nil))
(dolist (obj '(a (a . a) (a a . a)))
(should-error (eudc-plist-get obj nil) :type 'wrong-type-argument))
(dolist (plist '((nil) (a) (a a a)))
- (dolist (key '(nil a))
- (should (equal (should-error (eudc-plist-get plist key))
- '(error "Malformed plist")))))
+ (let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
+ (dolist (key '(nil a))
+ (should (equal err (should-error (eudc-plist-get plist key)))))))
(let ((-nil (string ?n ?i ?l))
(-a (string ?a)))
(should-not (eudc-plist-get () nil))
(dolist (obj '(a (a . a) (a a . a)))
(should-error (eudc-lax-plist-get obj nil) :type 'wrong-type-argument))
(dolist (plist '((nil) (a) (a a a)))
- (dolist (key '(nil a))
- (should (equal (should-error (eudc-lax-plist-get plist key))
- '(error "Malformed plist")))))
+ (let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
+ (dolist (key '(nil a))
+ (should (equal err (should-error (eudc-lax-plist-get plist key)))))))
(let ((-nil (string ?n ?i ?l))
(-a (string ?a)))
(should-not (eudc-lax-plist-get () nil))