diff options
| author | Stefan Kangas | 2020-07-31 06:09:09 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-08-04 18:45:10 +0200 |
| commit | b0e828da4f55d0dddcd8f8fc2e21e4b02a12852e (patch) | |
| tree | 4a31092d412add108362af0741ef64483686607b | |
| parent | 0a12d43e84eb5592c39350432c7a3e8fdaa71a06 (diff) | |
| download | emacs-b0e828da4f55d0dddcd8f8fc2e21e4b02a12852e.tar.gz emacs-b0e828da4f55d0dddcd8f8fc2e21e4b02a12852e.zip | |
Add new cconv-tests (Bug#28557)
These tests are all written by Gemini Lasswell <gazally@runbox.com>.
* test/lisp/emacs-lisp/cconv-tests.el
(top-level): Add two commented out tests which the byte-compiler
can't handle.
(cconv-tests-lambda-:documentation)
(cconv-tests-pcase-lambda-:documentation)
(cconv-tests-defun-:documentation)
(cconv-tests-cl-defun-:documentation)
(cconv-tests-function-:documentation)
(cconv-tests-cl-defgeneric-literal-:documentation)
(cconv-tests-defsubst-:documentation)
(cconv-tests-cl-defsubst-:documentation): New tests.
(cconv-tests-cl-iter-defun-:documentation)
(cconv-tests-iter-defun-:documentation)
(cconv-tests-iter-lambda-:documentation)
(cconv-tests-cl-function-:documentation)
(cconv-tests-cl-defgeneric-:documentation): New failing tests.
| -rw-r--r-- | test/lisp/emacs-lisp/cconv-tests.el | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cconv-tests.el b/test/lisp/emacs-lisp/cconv-tests.el index c8d46541ad4..148bcd69be1 100644 --- a/test/lisp/emacs-lisp/cconv-tests.el +++ b/test/lisp/emacs-lisp/cconv-tests.el | |||
| @@ -20,6 +20,164 @@ | |||
| 20 | ;;; Commentary: | 20 | ;;; Commentary: |
| 21 | 21 | ||
| 22 | (require 'ert) | 22 | (require 'ert) |
| 23 | (require 'cl-lib) | ||
| 24 | |||
| 25 | (ert-deftest cconv-tests-lambda-:documentation () | ||
| 26 | "Docstring for lambda can be specified with :documentation." | ||
| 27 | (let ((fun (lambda () | ||
| 28 | (:documentation (concat "lambda" " documentation")) | ||
| 29 | 'lambda-result))) | ||
| 30 | (should (string= (documentation fun) "lambda documentation")) | ||
| 31 | (should (eq (funcall fun) 'lambda-result)))) | ||
| 32 | |||
| 33 | (ert-deftest cconv-tests-pcase-lambda-:documentation () | ||
| 34 | "Docstring for pcase-lambda can be specified with :documentation." | ||
| 35 | (let ((fun (pcase-lambda (`(,a ,b)) | ||
| 36 | (:documentation (concat "pcase-lambda" " documentation")) | ||
| 37 | (list b a)))) | ||
| 38 | (should (string= (documentation fun) "pcase-lambda documentation")) | ||
| 39 | (should (equal '(2 1) (funcall fun '(1 2)))))) | ||
| 40 | |||
| 41 | (defun cconv-tests-defun () | ||
| 42 | (:documentation (concat "defun" " documentation")) | ||
| 43 | 'defun-result) | ||
| 44 | (ert-deftest cconv-tests-defun-:documentation () | ||
| 45 | "Docstring for defun can be specified with :documentation." | ||
| 46 | (should (string= (documentation 'cconv-tests-defun) | ||
| 47 | "defun documentation")) | ||
| 48 | (should (eq (cconv-tests-defun) 'defun-result))) | ||
| 49 | |||
| 50 | (cl-defun cconv-tests-cl-defun () | ||
| 51 | (:documentation (concat "cl-defun" " documentation")) | ||
| 52 | 'cl-defun-result) | ||
| 53 | (ert-deftest cconv-tests-cl-defun-:documentation () | ||
| 54 | "Docstring for cl-defun can be specified with :documentation." | ||
| 55 | (should (string= (documentation 'cconv-tests-cl-defun) | ||
| 56 | "cl-defun documentation")) | ||
| 57 | (should (eq (cconv-tests-cl-defun) 'cl-defun-result))) | ||
| 58 | |||
| 59 | ;; FIXME: The byte-complier croaks on this. See Bug#28557. | ||
| 60 | ;; (defmacro cconv-tests-defmacro () | ||
| 61 | ;; (:documentation (concat "defmacro" " documentation")) | ||
| 62 | ;; '(quote defmacro-result)) | ||
| 63 | ;; (ert-deftest cconv-tests-defmacro-:documentation () | ||
| 64 | ;; "Docstring for defmacro can be specified with :documentation." | ||
| 65 | ;; (should (string= (documentation 'cconv-tests-defmacro) | ||
| 66 | ;; "defmacro documentation")) | ||
| 67 | ;; (should (eq (cconv-tests-defmacro) 'defmacro-result))) | ||
| 68 | |||
| 69 | ;; FIXME: The byte-complier croaks on this. See Bug#28557. | ||
| 70 | ;; (cl-defmacro cconv-tests-cl-defmacro () | ||
| 71 | ;; (:documentation (concat "cl-defmacro" " documentation")) | ||
| 72 | ;; '(quote cl-defmacro-result)) | ||
| 73 | ;; (ert-deftest cconv-tests-cl-defmacro-:documentation () | ||
| 74 | ;; "Docstring for cl-defmacro can be specified with :documentation." | ||
| 75 | ;; (should (string= (documentation 'cconv-tests-cl-defmacro) | ||
| 76 | ;; "cl-defmacro documentation")) | ||
| 77 | ;; (should (eq (cconv-tests-cl-defmacro) 'cl-defmacro-result))) | ||
| 78 | |||
| 79 | (cl-iter-defun cconv-tests-cl-iter-defun () | ||
| 80 | (:documentation (concat "cl-iter-defun" " documentation")) | ||
| 81 | (iter-yield 'cl-iter-defun-result)) | ||
| 82 | (ert-deftest cconv-tests-cl-iter-defun-:documentation () | ||
| 83 | "Docstring for cl-iter-defun can be specified with :documentation." | ||
| 84 | ;; FIXME: See Bug#28557. | ||
| 85 | :expected-result :failed | ||
| 86 | (should (string= (documentation 'cconv-tests-cl-iter-defun) | ||
| 87 | "cl-iter-defun documentation")) | ||
| 88 | (should (eq (iter-next (cconv-tests-cl-iter-defun)) | ||
| 89 | 'cl-iter-defun-result))) | ||
| 90 | |||
| 91 | (iter-defun cconv-tests-iter-defun () | ||
| 92 | (:documentation (concat "iter-defun" " documentation")) | ||
| 93 | (iter-yield 'iter-defun-result)) | ||
| 94 | (ert-deftest cconv-tests-iter-defun-:documentation () | ||
| 95 | "Docstring for iter-defun can be specified with :documentation." | ||
| 96 | ;; FIXME: See Bug#28557. | ||
| 97 | :expected-result :failed | ||
| 98 | (should (string= (documentation 'cconv-tests-iter-defun) | ||
| 99 | "iter-defun documentation")) | ||
| 100 | (should (eq (iter-next (cconv-tests-iter-defun)) 'iter-defun-result))) | ||
| 101 | |||
| 102 | (ert-deftest cconv-tests-iter-lambda-:documentation () | ||
| 103 | "Docstring for iter-lambda can be specified with :documentation." | ||
| 104 | ;; FIXME: See Bug#28557. | ||
| 105 | :expected-result :failed | ||
| 106 | (let ((iter-fun | ||
| 107 | (iter-lambda () | ||
| 108 | (:documentation (concat "iter-lambda" " documentation")) | ||
| 109 | (iter-yield 'iter-lambda-result)))) | ||
| 110 | (should (string= (documentation iter-fun) "iter-lambda documentation")) | ||
| 111 | (should (eq (iter-next (funcall iter-fun)) 'iter-lambda-result)))) | ||
| 112 | |||
| 113 | (ert-deftest cconv-tests-cl-function-:documentation () | ||
| 114 | "Docstring for cl-function can be specified with :documentation." | ||
| 115 | ;; FIXME: See Bug#28557. | ||
| 116 | :expected-result :failed | ||
| 117 | (let ((fun (cl-function (lambda (&key arg) | ||
| 118 | (:documentation (concat "cl-function" | ||
| 119 | " documentation")) | ||
| 120 | (list arg 'cl-function-result))))) | ||
| 121 | (should (string= (documentation fun) "cl-function documentation")) | ||
| 122 | (should (equal (funcall fun :arg t) '(t cl-function-result))))) | ||
| 123 | |||
| 124 | (ert-deftest cconv-tests-function-:documentation () | ||
| 125 | "Docstring for lambda inside function can be specified with :documentation." | ||
| 126 | (let ((fun #'(lambda (arg) | ||
| 127 | (:documentation (concat "function" " documentation")) | ||
| 128 | (list arg 'function-result)))) | ||
| 129 | (should (string= (documentation fun) "function documentation")) | ||
| 130 | (should (equal (funcall fun t) '(t function-result))))) | ||
| 131 | |||
| 132 | (fmakunbound 'cconv-tests-cl-defgeneric) | ||
| 133 | (setplist 'cconv-tests-cl-defgeneric nil) | ||
| 134 | (cl-defgeneric cconv-tests-cl-defgeneric (n) | ||
| 135 | (:documentation (concat "cl-defgeneric" " documentation"))) | ||
| 136 | (cl-defmethod cconv-tests-cl-defgeneric ((n integer)) | ||
| 137 | (:documentation (concat "cl-defmethod" " documentation")) | ||
| 138 | (+ 1 n)) | ||
| 139 | (ert-deftest cconv-tests-cl-defgeneric-:documentation () | ||
| 140 | "Docstring for cl-defgeneric can be specified with :documentation." | ||
| 141 | ;; FIXME: See Bug#28557. | ||
| 142 | :expected-result :failed | ||
| 143 | (let ((descr (describe-function 'cconv-tests-cl-defgeneric))) | ||
| 144 | (set-text-properties 0 (length descr) nil descr) | ||
| 145 | (should (string-match-p "cl-defgeneric documentation" descr)) | ||
| 146 | (should (string-match-p "cl-defmethod documentation" descr))) | ||
| 147 | (should (= 11 (cconv-tests-cl-defgeneric 10)))) | ||
| 148 | |||
| 149 | (fmakunbound 'cconv-tests-cl-defgeneric-literal) | ||
| 150 | (setplist 'cconv-tests-cl-defgeneric-literal nil) | ||
| 151 | (cl-defgeneric cconv-tests-cl-defgeneric-literal (n) | ||
| 152 | (:documentation "cl-defgeneric-literal documentation")) | ||
| 153 | (cl-defmethod cconv-tests-cl-defgeneric-literal ((n integer)) | ||
| 154 | (:documentation "cl-defmethod-literal documentation") | ||
| 155 | (+ 1 n)) | ||
| 156 | (ert-deftest cconv-tests-cl-defgeneric-literal-:documentation () | ||
| 157 | "Docstring for cl-defgeneric can be specified with :documentation." | ||
| 158 | (let ((descr (describe-function 'cconv-tests-cl-defgeneric-literal))) | ||
| 159 | (set-text-properties 0 (length descr) nil descr) | ||
| 160 | (should (string-match-p "cl-defgeneric-literal documentation" descr)) | ||
| 161 | (should (string-match-p "cl-defmethod-literal documentation" descr))) | ||
| 162 | (should (= 11 (cconv-tests-cl-defgeneric-literal 10)))) | ||
| 163 | |||
| 164 | (defsubst cconv-tests-defsubst () | ||
| 165 | (:documentation (concat "defsubst" " documentation")) | ||
| 166 | 'defsubst-result) | ||
| 167 | (ert-deftest cconv-tests-defsubst-:documentation () | ||
| 168 | "Docstring for defsubst can be specified with :documentation." | ||
| 169 | (should (string= (documentation 'cconv-tests-defsubst) | ||
| 170 | "defsubst documentation")) | ||
| 171 | (should (eq (cconv-tests-defsubst) 'defsubst-result))) | ||
| 172 | |||
| 173 | (cl-defsubst cconv-tests-cl-defsubst () | ||
| 174 | (:documentation (concat "cl-defsubst" " documentation")) | ||
| 175 | 'cl-defsubst-result) | ||
| 176 | (ert-deftest cconv-tests-cl-defsubst-:documentation () | ||
| 177 | "Docstring for cl-defsubst can be specified with :documentation." | ||
| 178 | (should (string= (documentation 'cconv-tests-cl-defsubst) | ||
| 179 | "cl-defsubst documentation")) | ||
| 180 | (should (eq (cconv-tests-cl-defsubst) 'cl-defsubst-result))) | ||
| 23 | 181 | ||
| 24 | (ert-deftest cconv-convert-lambda-lifted () | 182 | (ert-deftest cconv-convert-lambda-lifted () |
| 25 | "Bug#30872." | 183 | "Bug#30872." |