]> code.delx.au - gnu-emacs/blobdiff - test/automated/cl-lib-tests.el
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Optimize &aux.
[gnu-emacs] / test / automated / cl-lib-tests.el
index 1c36e7d7abff729050888797854a5d7e2198eaf6..2c188a40059399660edefbd35f34ff5d6452f905 100644 (file)
 (ert-deftest cl-flet-test ()
   (should (equal (cl-flet ((f1 (x) x)) (let ((x #'f1)) (funcall x 5))) 5)))
 
+(ert-deftest cl-lib-test-typep ()
+  (cl-deftype cl-lib-test-type (&optional x) `(member ,x))
+  ;; Make sure we correctly implement the rule that deftype's optional args
+  ;; default to `*' rather than to nil.
+  (should (cl-typep '* 'cl-lib-test-type))
+  (should-not (cl-typep 1 'cl-lib-test-type)))
+
+(ert-deftest cl-lib-arglist-performance ()
+  ;; An `&aux' should not cause lambda's arglist to be turned into an &rest
+  ;; that's parsed by hand.
+  (should (eq () (nth 1 (nth 1 (macroexpand
+                                '(cl-function (lambda (&aux (x 1)) x)))))))
+  (cl-defstruct (cl-lib--s (:constructor cl-lib--s-make (&optional a))) a)
+  ;; Similarly the &cl-defs thingy shouldn't cause fallback to manual parsing
+  ;; of args if the default for optional args is nil.
+  (should (equal '(&optional a) (help-function-arglist 'cl-lib--s-make))))
+
 ;;; cl-lib.el ends here