]> git.eshelyaron.com Git - emacs.git/commitdiff
Make lexical-binding cookie warning test more robust
authorMattias EngdegÄrd <mattiase@acm.org>
Wed, 3 Apr 2024 09:27:16 +0000 (11:27 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 4 Apr 2024 11:39:05 +0000 (13:39 +0200)
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--lexical-binding-cookie):
Run with lexical-binding both on and off.

(cherry picked from commit 0c55261971b0fea62a8e94204e544ff8af714a2e)

test/lisp/emacs-lisp/bytecomp-tests.el

index 26408e8685ad9a90860e14a142e471e0659177a4..a943012e5fc7e1dc382fa310acde14709db0b782 100644 (file)
@@ -1348,12 +1348,14 @@ byte-compiled.  Run with dynamic binding."
               (string-search
                "file has no `lexical-binding' directive on its first line"
                (bytecomp-tests--log-from-compilation source))))
-    (let ((some-code "(defun my-fun () 12)\n"))
-      (should-not (cookie-warning
-                   (concat ";;; -*-lexical-binding:t-*-\n" some-code)))
-      (should-not (cookie-warning
-                   (concat ";;; -*-lexical-binding:nil-*-\n" some-code)))
-      (should (cookie-warning some-code)))))
+    (dolist (lb '(t nil))
+      (let ((lexical-binding lb)
+            (some-code "(defun my-fun () 12)\n"))
+        (should-not (cookie-warning
+                     (concat ";;; -*-lexical-binding:t-*-\n" some-code)))
+        (should-not (cookie-warning
+                     (concat ";;; -*-lexical-binding:nil-*-\n" some-code)))
+        (should (cookie-warning some-code))))))
 
 (ert-deftest bytecomp-tests--unescaped-char-literals ()
   "Check that byte compiling warns about unescaped character