summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-05-12 00:10:38 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-05-12 00:10:38 -0400
commitd1b74200dad00cea845037064dc8b5d50db35dd2 (patch)
tree51102ad11a51f14177fa58dc601a536cac40d0ca /test
parentf0352ebdf088bea19b44ddb31e94888bc2345a24 (diff)
downloademacs-d1b74200dad00cea845037064dc8b5d50db35dd2.tar.gz
* lisp/emacs-lisp/cl-generic.el: Add dispatch on &context arguments
(cl--generic-mandatory-args): Remove. (cl--generic-split-args): New function. (cl-generic-define, cl--generic-lambda): Use it. (cl-generic-define-method): Use it as well, and add support for context args. (cl--generic-get-dispatcher): Handle &context dispatch. (cl--generic-cache-miss): `dispatch-arg' can now be a context expression. (cl--generic-dispatchers): Pre-fill. * test/automated/cl-generic-tests.el (sm-generic-test-12-context): New test.
Diffstat (limited to 'test')
-rw-r--r--test/automated/cl-generic-tests.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/automated/cl-generic-tests.el b/test/automated/cl-generic-tests.el
index 5194802fa00..a6035d1cba2 100644
--- a/test/automated/cl-generic-tests.el
+++ b/test/automated/cl-generic-tests.el
@@ -179,5 +179,15 @@
(cl-list* "quatre" (cl-next-method-p) (cl-call-next-method)))
(should (equal (cl--generic-1 4 5) '("quatre" t 4 5 nil))))
+(ert-deftest sm-generic-test-12-context ()
+ (cl-defgeneric cl--generic-1 ())
+ (cl-defmethod cl--generic-1 (&context (overwrite-mode (eql t))) 'is-t)
+ (cl-defmethod cl--generic-1 (&context (overwrite-mode (eql nil))) 'is-nil)
+ (cl-defmethod cl--generic-1 () 'other)
+ (should (equal (list (let ((overwrite-mode t)) (cl--generic-1))
+ (let ((overwrite-mode nil)) (cl--generic-1))
+ (let ((overwrite-mode 1)) (cl--generic-1)))
+ '(is-t is-nil other))))
+
(provide 'cl-generic-tests)
;;; cl-generic-tests.el ends here