emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 46d11bc 2/2: checkdoc CL tests


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 46d11bc 2/2: checkdoc CL tests
Date: Wed, 9 Oct 2019 20:26:38 -0400 (EDT)

branch: master
commit 46d11bcfa381c13a9719b7ecd3f9d4cc92c34089
Author: Damien Cassou <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    checkdoc CL tests
    
    * test/lisp/emacs-lisp/checkdoc-tests.el: Add cl-lib-related tests
    (bug#37063).
---
 test/lisp/emacs-lisp/checkdoc-tests.el | 106 +++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el 
b/test/lisp/emacs-lisp/checkdoc-tests.el
index 1cefc4c..de75c42 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -37,6 +37,112 @@
     (insert "(defun foo())")
     (should-error (checkdoc-defun) :type 'user-error)))
 
+(ert-deftest checkdoc-cl-defmethod-ok ()
+  "Checkdoc should be happy with a simple correct cl-defmethod."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defmethod foo (a) \"Return A.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defmethod-with-types-ok ()
+  "Checkdoc should be happy with a cl-defmethod using types."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    ;; this method matches if A is the symbol `smthg' and if b is a list:
+    (insert "(cl-defmethod foo ((a (eql smthg)) (b list)) \"Return A+B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-key-ok ()
+  "Checkdoc should be happy with a cl-defun using &key."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo (&key a (b 27)) \"Return :A+:B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-allow-other-keys-ok ()
+  "Checkdoc should be happy with a cl-defun using &allow-other-keys."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo (&key a &allow-other-keys) \"Return :A.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-default-optional-value-ok ()
+  "Checkdoc should be happy with a cl-defun using default values for optional 
args."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    ;; B is optional and equals 1+a if not provided. HAS-BS is non-nil
+    ;; if B was provided in the call:
+    (insert "(cl-defun foo (a &optional (b (1+ a) has-bs)) \"Return A + B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-destructuring-ok ()
+  "Checkdoc should be happy with a cl-defun destructuring its arguments."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo ((a b &optional c) d) \"Return A+B+C+D.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defmethod-ok ()
+  "Checkdoc should be happy with a simple correct cl-defmethod."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defmethod foo (a) \"Return A.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defmethod-with-types-ok ()
+  "Checkdoc should be happy with a cl-defmethod using types."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    ;; this method matches if A is the symbol `smthg' and if b is a list:
+    (insert "(cl-defmethod foo ((a (eql smthg)) (b list)) \"Return A+B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-key-ok ()
+  "Checkdoc should be happy with a cl-defun using &key."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo (&key a (b 27)) \"Return :A+:B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-allow-other-keys-ok ()
+  "Checkdoc should be happy with a cl-defun using &allow-other-keys."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo (&key a &allow-other-keys) \"Return :A.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-aux-ok ()
+  "Checkdoc should be happy with a cl-defun using &aux."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo (a b &aux (c (+ a b))) \"Return A and B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-default-optional-value-ok ()
+  "Checkdoc should be happy with a cl-defun using default values for optional 
args."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    ;; B is optional and equals 1+a if not provided. HAS-BS is non-nil
+    ;; if B was provided in the call:
+    (insert "(cl-defun foo (a &optional (b (1+ a) has-bs)) \"Return A + B.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defun-with-destructuring-ok ()
+  "Checkdoc should be happy with a cl-defun destructuring its arguments."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(cl-defun foo ((a b &optional c) d) \"Return A+B+C+D.\")")
+    (checkdoc-defun)))
+
+(ert-deftest checkdoc-cl-defmethod-with-context-ok ()
+  "Checkdoc should ignore context specializers in a cl-defmethod."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    ;; A context specializer is used to select the correct method but
+    ;; doesn't have to appear in the docstring:
+    (insert "(cl-defmethod foo (a &context (global-var (eql foo))) \"Return 
A.\")")
+    (checkdoc-defun)))
+
 (ert-deftest checkdoc-tests--next-docstring ()
   "Checks that the one-argument form of `defvar' works.
 See the comments in Bug#24998."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]