From 0b099e34dc726c3ed0e7b63028f42c2a2720ba7c Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Thu, 23 Sep 2021 14:02:21 +0200 Subject: 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. --- test/lisp/emacs-lisp/ert-tests.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 5c9696105e9..a18664bba3b 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el @@ -816,6 +816,10 @@ This macro is used to test if macroexpansion in `should' works." (should (equal (ert-test-failed-condition result) '(ert-test-failed "Boo"))))) +(ert-deftest ert-test-deftest-lexical-binding-t () + "Check that `lexical-binding' in `ert-deftest' has the file value." + (should (equal lexical-binding t))) + (provide 'ert-tests) -- cgit v1.2.3