diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-09-23 14:02:21 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-09-25 20:25:01 +0200 |
commit | 0b099e34dc726c3ed0e7b63028f42c2a2720ba7c (patch) | |
tree | 4e6c5463ac3f8388286d4508fba4046631822f8d /lisp/emacs-lisp/ert.el | |
parent | ed02b88bbae18caad650d76876940ffb58cab554 (diff) | |
download | emacs-0b099e34dc726c3ed0e7b63028f42c2a2720ba7c.tar.gz emacs-0b099e34dc726c3ed0e7b63028f42c2a2720ba7c.tar.bz2 emacs-0b099e34dc726c3ed0e7b63028f42c2a2720ba7c.zip |
Use ambient lexical-binding value in ert-deftest body (bug#50738)
* lisp/emacs-lisp/ert.el (ert-deftest):
Evaluate the body of `ert-deftest` with the `lexical-binding` value of
the source file (or more precisely the value in force when the
definition is evaluated), which is what everyone expected, instead of
always using dynamic binding which is what they got until now.
* test/lisp/emacs-lisp/ert-tests.el
(ert-test-deftest-lexical-binding-t): New test.
Diffstat (limited to 'lisp/emacs-lisp/ert.el')
-rw-r--r-- | lisp/emacs-lisp/ert.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index d4d8510064a..6d867abd7a2 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -218,7 +218,11 @@ it has to be wrapped in `(eval (quote ...))'. `(:expected-result-type ,expected-result)) ,@(when tags-supplied-p `(:tags ,tags)) - :body (lambda () ,@body))) + :body (lambda () + ;; Use the value of `lexical-binding' in + ;; the source file when evaluating the body. + (let ((lexical-binding ,lexical-binding)) + ,@body)))) ',name)))) (defvar ert--find-test-regexp |