summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/cl-macs-tests.el
Commit message (Collapse)AuthorAgeFilesLines
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
|
* Fix &key parameters called without arguments (bug#58714)Gerd Möllmann2022-11-111-0/+6
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl--do-arglist): Check for missing argument. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-&key-arguments): New test.
* Improve check for misleading 'cl-case' cases (Bug#57915).Philipp Stephani2022-09-191-0/+11
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Check that the case is of the form (quote FOO), not just (quote). * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-no-warning): New unit test.
* Fix recently-added cl-macs testsLars Ingebrigtsen2022-09-141-32/+34
| | | | | * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-error) (cl-case-warning): Fix warning matches.
* Have 'cl-case' warn about suspicious casesPhilipp Stephani2022-09-131-0/+32
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil key list (which would never match). Warn about quoted symbols that should probably be unquoted. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit test (bug#51368).
* Signal an error if a fallback cl-case is misplacedPhilipp Stephani2022-09-131-0/+11
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil key list (which would never match). Warn about quoted symbols that should probably be unquoted. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit test (bug#51368).
* cl-symbol-macrolet: Fix recent regressionStefan Monnier2022-09-061-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The recent fix for bug#57397 introduced a regression, breaking the `cl-lib-symbol-macrolet-hide` test. It turned out that the origin of the problem was that `gv.el` uses `macroexpand-1` which does not (can't) use `macroexpand` but `cl-symbol-macrolet` failed to advise `macroexpand-1` the way it advised `macroexpand`. To fix this, we change `cl-symbol-macrolet` so it advises both, and we do that with a new `macroexpand` advice which delegates the bulk of the work to `macroexpand-1`. Along the way, I bumped into another bug in the interaction between `cl-letf` and `cl-symbol-macrolet`, which I tried to fix in `cl-letf`. I hear the war on `cl-symbol-macrolet` was a failure. Maybe ... just say no? * lisp/emacs-lisp/cl-macs.el (cl--sm-macroexpand-1): New function, extracted from `cl--sm-macroexpand`. (cl--sm-macroexpand): Rewrite completely. (cl-symbol-macrolet): Advise both `macroexpand` and `macroexpand-1`. (cl--letf): Don't use the "simple variable" code for symbol macros. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-symbol-macrolet-hide): Revert last change because the test was right. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): Add a test case.
* gv.el and cl-macs.el: Fix bug#57397Stefan Monnier2022-09-031-1/+14
| | | | | | | | | * lisp/emacs-lisp/gv.el (gv-get): Obey symbol macros. * lisp/emacs-lisp/cl-macs.el (cl--letf): Remove workaround placed to try and handle symbol macros. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): Add new testcase.
* Make Edebug specification for 'cl-defstruct' more lenient.Philipp Stephani2022-03-141-0/+18
| | | | | | | | | For example, 'xref-item' uses the list form of ':noinline'. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Accept ':noinline' and ':named' with an argument. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/edebug): New unit test.
* Teach Edebug about the special '&whole' syntax for compiler macros.Philipp Stephani2022-03-031-0/+15
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro-list): New Edebug element specification. (cl-define-compiler-macro): Use it. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-define-compiler-macro/edebug): New unit test.
* Merge from origin/emacs-28Eli Zaretskii2022-01-011-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year. 86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year ebe8772f65 ; Minor fixes related to copyright years 23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye... 8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t. 19dcb237b5 ; Add 2022 to copyright years. # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex # lib/cdefs.h # lisp/erc/erc-dcc.el # lisp/erc/erc-imenu.el # lisp/erc/erc-replace.el # lisp/image-dired.el # lisp/progmodes/xref.el # m4/alloca.m4 # m4/byteswap.m4 # m4/errno_h.m4 # m4/getopt.m4 # m4/gnulib-common.m4 # m4/inttypes.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/sys_socket_h.m4
| * ; Add 2022 to copyright years.Eli Zaretskii2022-01-011-1/+1
| |
* | Body of dynamic let-bindings is not in tail positionMattias Engdegård2021-12-201-1/+18
| | | | | | | | | | | | | | | | This fixes a known bug in `named-let`. * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Prevent TCO from inside dynamic variable bindings. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test.
* | * test/lisp/emacs-lisp/cl-macs-tests.el: Avoid `with-suppressed-warnings`Stefan Monnier2021-12-081-6/+6
| | | | | | | | | | * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--progv): Use a proper namespace prefix for the global vars.
* | Silence byte-compiler in some testsStefan Kangas2021-12-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/dired-tests.el: * test/lisp/emacs-lisp/cl-macs-tests.el: * test/lisp/emacs-lisp/derived-tests.el: * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el: * test/lisp/emacs-lisp/generator-tests.el: * test/lisp/emacs-lisp/lisp-tests.el: * test/lisp/emacs-lisp/seq-tests.el (test-seq-let) (test-seq-setq): * test/lisp/emacs-lisp/subr-x-tests.el (subr-x-test-if-let*-false) (subr-x-test-if-let*-and-laziness-is-preserved) (subr-x-test-when-let*-false) (subr-x-test-when-let*-and-laziness-is-preserved): * test/lisp/emacs-lisp/timer-tests.el (timer-tests-debug-timer-check): * test/lisp/format-spec-tests.el (format-spec-do-flags-truncate) (format-spec-do-flags-pad): * test/lisp/ls-lisp-tests.el (ls-lisp-test-bug27762): * test/lisp/obsolete/cl-tests.el (labels-function-quoting): * test/lisp/progmodes/elisp-mode-tests.el: * test/lisp/replace-tests.el (replace-regexp-bug45973): * test/lisp/ses-tests.el: * test/lisp/subr-tests.el: * test/lisp/tar-mode-tests.el (tar-mode-test-tar-grind-file-mode): * test/src/data-tests.el (data-tests--set-default-per-buffer): * test/src/search-tests.el (test-replace-match-modification-hooks): Silence byte-compiler.
* | Make 'eval' use lexical scoping in most testsStefan Kangas2021-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/electric-tests.el (electric-pair-define-test-form) (define-electric-pair-test): * test/lisp/emacs-lisp/backtrace-tests.el (backtrace-tests--uncompiled-functions): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): * test/lisp/emacs-lisp/let-alist-tests.el (let-alist-list-to-sexp): * test/lisp/emacs-lisp/lisp-tests.el (elisp-tests-with-temp-buffer, core-elisp-tests-3-backquote): * test/lisp/emacs-lisp/testcover-resources/testcases.el (testcover-testcase-nth-case): * test/lisp/ffap-tests.el (ffap-ido-mode): * test/lisp/files-tests.el (file-test--do-local-variables-test): * test/lisp/net/tramp-tests.el (tramp--test-utf8): * test/lisp/progmodes/elisp-mode-tests.el (find-defs-defgeneric-eval, find-defs-defun-eval) (find-defs-defvar-eval, find-defs-face-eval) (find-defs-feature-eval): Give 'eval' non-nil LEXICAL argument. * test/lisp/subr-tests.el (subr-tests--dolist--wrong-number-of-args): * test/src/eval-tests.el (eval-tests--if-dot-string) (eval-tests--mutating-cond) (eval-tests-19790-backquote-comma-dot-substitution): Test 'eval' using LEXICAL as both nil and non-nil. (eval-tests--let-with-circular-defs): Give explicit nil to 'eval'.
* | Improve TCO test coverageMattias Engdegård2021-10-191-2/+11
|/ | | | | * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Exercise `cond` in tail position in two different ways.
* Add condition-case success handler (bug#47677)Mattias Engdegård2021-04-151-4/+5
| | | | | | | | | | | | | | | | | | | | Allow a condition-case handler on the form (:success BODY) to be specified as the success continuation of the protected form, with the specified variable bound to its result. * src/eval.c (Fcondition_case): Update the doc string. (internal_lisp_condition_case): Implement in interpreter. (syms_of_eval): Defsym :success. * lisp/emacs-lisp/bytecomp.el (byte-compile-condition-case): Implement in byte-compiler. * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Allow self-TCO from success handler. * doc/lispref/control.texi (Handling Errors): Update manual. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases) (bytecomp-condition-case-success): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test cases.
* Self-TCO in `condition-case` error handlersMattias Engdegård2021-04-091-2/+12
| | | | | | | * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Recognise `condition-case` handlers as being in the tail position. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Extend test.
* Fix cl-progv binding orderToby Cubitt2021-03-201-0/+5
| | | | | * lisp/emacs-lisp/cl-macs.el (cl-progv): Bind variables in the correct order (bug#47272).
* Optimise tail calls in `and` and `or` forms in `cl-labels` functionsMattias Engdegård2021-03-181-5/+20
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Handle `and` and `or`. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test cases.
* ; Minor license statement fixesStefan Kangas2021-02-081-11/+11
|
* * lisp/emacs-lisp/cl-macs.el: Optimize self-calls in tail positionStefan Monnier2021-01-081-1/+16
| | | | | | | | | | | | | | | | | | | Implement a limited form of tail-call optimization for the special case of recursive functions defined with `cl-labels`. Only self-recursion is optimized, no attempt is made to handle more complex cases such a mutual recursion. The main benefit is to reduce the use of the stack, tho in my limited tests, this can also improve performance (about half of the way to a hand-written `while` loop). (cl--self-tco): New function. (cl-labels): Use it. * lisp/subr.el (letrec): Optimize single-binding corner case. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add tests to check that TCO is working.
* * lisp/subr.el (letrec): Optimize some non-recursive bindingsStefan Monnier2021-01-081-0/+8
| | | | | | | | * lisp/emacs-lisp/macroexp.el (macroexp--fgrep): Look inside bytecode objects as well. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): * test/lisp/subr-tests.el (subr--tests-letrec): New tests.
* Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Allow destructuring in &aux sections when using edebug (Bug#40431)Philipp Stephani2020-06-101-0/+9
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-lambda-list, cl-lambda-list1) (cl-macro-list, cl-macro-list1): Allow arbitrary 'cl-lambda' arguments in the &aux section. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-aux-edebug): New regression test.
* Don’t attempt to modify constant stringsPaul Eggert2020-05-161-1/+3
| | | | | | | | | | | | | | | | | | | | | * lisp/bookmark.el (bookmark-bmenu-set-header): Use copy-sequence instead of concat, for clarity. Also, the byte-compiler optimizes (concat "a" "b") into "ab". * lisp/button.el (make-text-button): * test/lisp/erc/erc-track-tests.el (erc-track--erc-faces-in): * test/lisp/password-cache-tests.el: (password-cache-tests-add-and-remove) (password-cache-tests-read-from-cache) (password-cache-tests-in-cache-p, password-cache-tests-read) (password-cache-tests-reset) (password-cache-tests-add/expires-key) (password-cache-tests-no-password-cache): Don’t attempt to modify constant strings. * lisp/progmodes/elisp-mode.el (elisp--xref-format) (elisp--xref-format-extra): Don’t attempt to modify constant strings via put-text-property. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-across-ref): Don’t attempt to modify constant vectors or strings.
* Don't increment array index in cl-loop twice (Bug#40727)Noam Postavsky2020-05-071-0/+3
| | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause): Put the temp-idx increment in cl--loop-body, leaving just the side-effect free testing of the index for both cl--loop-body and cl--loop-conditions. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-and-arrays): Extend test to cover this case.
* Revert "cl-loop: Calculate the array length just once"Noam Postavsky2020-05-071-0/+6
| | | | | | | | It fails when using 'and' (parallel bindings) for arrays (Bug#40727). * lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause): Revert to recomputing array length. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-and-arrays): New test.
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* ; Spelling fixesPaul Eggert2019-12-101-2/+2
|
* Refix conditional step clauses in cl-loopdickmao2019-11-221-4/+64
| | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl--loop-bindings, cl--loop-symbol-macs, cl-loop): Add cl--loop-conditions, remove cl--loop-guard-cond. (cl--push-clause-loop-body): Apply clause to both cl--loop-conditions and cl--loop-body (cl--parse-loop-clause): Use cl--push-clause-loop-body. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-and-assignment): Use docstring. (cl-macs-loop-for-as-arith): Removed expected failure. (cl-macs-loop-conditional-step-clauses): Add some tests (bug#29799).
* * cl-macs-tests.el (cl-macs-test--symbol-macrolet): New testStefan Monnier2019-05-161-0/+17
|
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* | Prevent name clashes between CL structures and builtin typesPhilipp Stephani2018-01-281-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't allow structures with the same names as builtin types. (cl--typeof-types, cl--all-builtin-types): Move from cl-generic.el and rename. (cl--struct-name-p): New helper function. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Don't allow structures with the same names as builtin types. * lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-generalizer) (cl-generic-generalizers): Adapt to name change. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/builtin-type): * test/lisp/emacs-lisp/cl-preloaded-tests.el (cl-struct-define/builtin-type): New unit tests. * etc/NEWS: Document changed behavior.
* | cl-loop: Add missing guard conditionTino Calancha2018-01-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the expansion of `cl-loop' with a `for' clause and more than one internal variables, X, Y, processed in parallel. Each step updates X and Y right after update the loop variable, K; if either X or Y depend on K, then some forms of the body are evaluated with the wrong K (Bug#29799). For instance, consider the following code: (cl-loop for k below 2 for x = (progn (message "k = %d" k) 1) and y = 1) This code should show in *Messages*: k = 0 k = 1 Instead, the code shows: k = 0 k = 1 k = 2 To prevent this we must ensure that the loop condition is still satisfied right after update the loop variable. In the macro expansion of the example above, right after: (setq k (+ k 1)) evaluate the rest of the body forms iif the condition (< k 2) is still valid. * lisp/emacs-lisp/cl-macs.el (cl--loop-guard-cond): New variable. (cl--parse-loop-clause): Set it non-nil if the loop contains a for/as clause. (cl-loop): After update the loop variable, evaluate the remaining of the body forms just if the loop condition is still valid (Bug#29799). * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-equals-and): New test.
* | Revert "Prevent name clashes between CL structures and builtin types"Philipp Stephani2018-01-071-9/+0
| | | | | | | | | | This reverts commit 151496a4b96430924bc148f85b9c8471d1e132b1. That commit breaks bootstrap builds due to a cyclic dependency.
* | Prevent name clashes between CL structures and builtin typesPhilipp Stephani2018-01-071-0/+9
|/ | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't allow structures with the same names as builtin types. (cl--struct-name-p): New helper function. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Don't allow structures with the same names as builtin types. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/builtin-type): * test/lisp/emacs-lisp/cl-preloaded-tests.el (cl-struct-define/builtin-type): New unit tests. * etc/NEWS: Document changed behavior.
* Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | Run admin/update-copyright.
* Partially revert "Mention new strictness for &optional, &rest..."Noam Postavsky2017-12-151-31/+0
| | | | | | | | | | | | | The changes to cl argument parsing are not backwards compatible, and cause inconvenience when writing macros (e.g., instead of doing '&aux ,@auxargs', some more complicated conditionals would be required). The `cl-defstruct' macro makes use of this convenience when defining empty structs (Bug#29728). * lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): (cl--do-&aux, cl--do-arglist): Undo strict checking of &rest, &key, and &aux. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-bad-arglist): Remove test.
* Mention new strictness for &optional, &rest in arglists (Bug#29165)Noam Postavsky2017-12-131-0/+31
| | | | | | | | | | * etc/NEWS: Explain that '&optional' not followed by a variable is now an error. * lisp/emacs-lisp/cl-macs.el (cl--transform-lambda, cl--do-&aux) (cl--do-arglist): Also reject '&optional', '&rest', or '&aux' not followed by a variable for consistency. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-bad-arglist): New test.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Add tests for cl-macs.el (Bug#27559)Alexander Gramiak2017-08-211-0/+500
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-loop): Remove duplicate. (cl-loop-destructuring-with): Move to cl-macs-tests.el. * test/lisp/emacs-lisp/cl-macs-tests.el: New file.