]> git.eshelyaron.com Git - emacs.git/commitdiff
Gather variable binding tests in data-tests.el
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 30 May 2025 10:41:06 +0000 (11:41 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 7 Jun 2025 19:53:42 +0000 (21:53 +0200)
* test/lisp/emacs-lisp/lisp-tests.el (c-e-x, c-e-l):
Move to data-tests.el.
(core-elisp-tests-2-window-configurations): Rename ...
(core-elisp-tests-1-window-configurations): ... to this.
(core-elisp-tests-3-backquote): Rename ...
(core-elisp-tests-2-backquote): ... to this.
(core-elisp-tests-1-defvar-in-let)
(core-elisp-tests-4-toplevel-values): Move and rename ...
* test/src/data-tests.el (binding-test-defvar-in-let)
(binding-test-toplevel-values): ... to these.
(c-e-x, c-e-l): Moved from data-tests.el.

(cherry picked from commit f699b6e4f409c0cc98703a2cea9b243ff8cb570a)

test/lisp/emacs-lisp/lisp-tests.el
test/src/data-tests.el

index 1ef6bc864a7db3f15f7802166d235e8e0df15d91..d7cdaa3b331f3a8b5933d4a4380dd31975ef818b 100644 (file)
     (goto-char (point-min))
     (should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error.
 
-;; Test some core Elisp rules.
-(defvar c-e-x)
-(ert-deftest core-elisp-tests-1-defvar-in-let ()
-  "Test some core Elisp rules."
-  (with-temp-buffer
-    ;; Check that when defvar is run within a let-binding, the toplevel default
-    ;; is properly initialized.
-    (should (equal (list (let ((c-e-x 1)) (defvar c-e-x 2) c-e-x) c-e-x)
-                   '(1 2)))
-    (should (equal (list (let ((c-e-x 1))
-                           (defcustom c-e-x 2 "doc" :group 'blah :type 'integer) c-e-x)
-                         c-e-x)
-                   '(1 2)))))
-
-(ert-deftest core-elisp-tests-2-window-configurations ()
+(ert-deftest core-elisp-tests-1-window-configurations ()
   "Test properties of window-configurations."
   (let ((wc (current-window-configuration)))
     (with-current-buffer (window-buffer (frame-selected-window))
     (set-window-configuration wc)
     (should (or (not mark-active) (mark)))))
 
-(ert-deftest core-elisp-tests-3-backquote ()
+;; For variable binding tests, see src/data-tests.el.
+(ert-deftest core-elisp-tests-2-backquote ()
   (should (eq 3 (eval ``,,'(+ 1 2) t))))
 
-(defvar-local c-e-l 'foo)
-(ert-deftest core-elisp-tests-4-toplevel-values ()
-  (setq-default c-e-l 'foo)
-  (let ((c-e-l 'bar))
-    (let ((c-e-l 'baz))
-      (setq-default c-e-l 'bar)
-      (should (eq c-e-l 'bar))
-      (should (eq (default-toplevel-value 'c-e-l) 'foo))
-      (set-default-toplevel-value 'c-e-l 'baz)
-      (should (eq c-e-l 'bar))
-      (should (eq (default-toplevel-value 'c-e-l) 'baz))))
-  (let ((c-e-u 'foo))
-    (should (condition-case _
-                (default-toplevel-value 'c-e-u)
-              (void-variable t))))
-  (with-temp-buffer
-    (setq-local c-e-l 'bar)
-    (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar))
-    (let ((c-e-l 'baz))
-      (let ((c-e-l 'quux))
-        (setq-local c-e-l 'baz)
-        (should (eq c-e-l 'baz))
-        (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar))
-        (set-buffer-local-toplevel-value 'c-e-l 'foo)
-        (should (eq c-e-l 'baz))
-        (should (eq (buffer-local-toplevel-value 'c-e-l) 'foo)))))
-  (with-temp-buffer
-    (should (condition-case _
-                (buffer-local-toplevel-value 'c-e-l)
-              (void-variable t)))))
-
 ;; Test up-list and backward-up-list.
 (defun lisp-run-up-list-test (fn data start instructions)
   (cl-labels ((posof (thing)
index 260bdb281bb584a109f144a1bef6f02040ba7201..75be985646317323cdfc004836fa56a8d044a8a6 100644 (file)
@@ -354,6 +354,19 @@ comparing the subr with a much slower Lisp implementation."
       (setq-default binding-test-some-local 'new-default))
     (should (eq binding-test-some-local 'some))))
 
+(defvar c-e-x)
+(ert-deftest binding-test-defvar-in-let ()
+  "Test some core Elisp rules."
+  (with-temp-buffer
+    ;; Check that when defvar is run within a let-binding, the toplevel default
+    ;; is properly initialized.
+    (should (equal (list (let ((c-e-x 1)) (defvar c-e-x 2) c-e-x) c-e-x)
+                   '(1 2)))
+    (should (equal (list (let ((c-e-x 1))
+                           (defcustom c-e-x 2 "doc" :group 'blah :type 'integer) c-e-x)
+                         c-e-x)
+                   '(1 2)))))
+
 (ert-deftest data-tests--let-buffer-local ()
   (let ((blvar (make-symbol "blvar")))
     (set-default blvar nil)
@@ -396,6 +409,37 @@ comparing the subr with a much slower Lisp implementation."
             (should (equal (default-value var) def)))
           )))))
 
+(defvar-local c-e-l 'foo)
+(ert-deftest binding-test-toplevel-values ()
+  (setq-default c-e-l 'foo)
+  (let ((c-e-l 'bar))
+    (let ((c-e-l 'baz))
+      (setq-default c-e-l 'bar)
+      (should (eq c-e-l 'bar))
+      (should (eq (default-toplevel-value 'c-e-l) 'foo))
+      (set-default-toplevel-value 'c-e-l 'baz)
+      (should (eq c-e-l 'bar))
+      (should (eq (default-toplevel-value 'c-e-l) 'baz))))
+  (let ((c-e-u 'foo))
+    (should (condition-case _
+                (default-toplevel-value 'c-e-u)
+              (void-variable t))))
+  (with-temp-buffer
+    (setq-local c-e-l 'bar)
+    (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar))
+    (let ((c-e-l 'baz))
+      (let ((c-e-l 'quux))
+        (setq-local c-e-l 'baz)
+        (should (eq c-e-l 'baz))
+        (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar))
+        (set-buffer-local-toplevel-value 'c-e-l 'foo)
+        (should (eq c-e-l 'baz))
+        (should (eq (buffer-local-toplevel-value 'c-e-l) 'foo)))))
+  (with-temp-buffer
+    (should (condition-case _
+                (buffer-local-toplevel-value 'c-e-l)
+              (void-variable t)))))
+
 (ert-deftest binding-test-makunbound ()
   "Tests of makunbound, from the manual."
   (with-current-buffer binding-test-buffer-B