diff options
| author | Sean Whitton | 2025-05-30 11:41:06 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-05-30 11:41:19 +0100 |
| commit | f699b6e4f409c0cc98703a2cea9b243ff8cb570a (patch) | |
| tree | cf2802bf84b0460b6516170dfaf6522e5fb098da | |
| parent | 30c2ef6d6ab73b913ee5c4da7b6cfc26477f5faa (diff) | |
| download | emacs-f699b6e4f409c0cc98703a2cea9b243ff8cb570a.tar.gz emacs-f699b6e4f409c0cc98703a2cea9b243ff8cb570a.zip | |
Gather variable binding tests in data-tests.el
* 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.
| -rw-r--r-- | test/lisp/emacs-lisp/lisp-tests.el | 50 | ||||
| -rw-r--r-- | test/src/data-tests.el | 44 |
2 files changed, 47 insertions, 47 deletions
diff --git a/test/lisp/emacs-lisp/lisp-tests.el b/test/lisp/emacs-lisp/lisp-tests.el index 1ef6bc864a7..d7cdaa3b331 100644 --- a/test/lisp/emacs-lisp/lisp-tests.el +++ b/test/lisp/emacs-lisp/lisp-tests.el | |||
| @@ -212,21 +212,7 @@ | |||
| 212 | (goto-char (point-min)) | 212 | (goto-char (point-min)) |
| 213 | (should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error. | 213 | (should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error. |
| 214 | 214 | ||
| 215 | ;; Test some core Elisp rules. | 215 | (ert-deftest core-elisp-tests-1-window-configurations () |
| 216 | (defvar c-e-x) | ||
| 217 | (ert-deftest core-elisp-tests-1-defvar-in-let () | ||
| 218 | "Test some core Elisp rules." | ||
| 219 | (with-temp-buffer | ||
| 220 | ;; Check that when defvar is run within a let-binding, the toplevel default | ||
| 221 | ;; is properly initialized. | ||
| 222 | (should (equal (list (let ((c-e-x 1)) (defvar c-e-x 2) c-e-x) c-e-x) | ||
| 223 | '(1 2))) | ||
| 224 | (should (equal (list (let ((c-e-x 1)) | ||
| 225 | (defcustom c-e-x 2 "doc" :group 'blah :type 'integer) c-e-x) | ||
| 226 | c-e-x) | ||
| 227 | '(1 2))))) | ||
| 228 | |||
| 229 | (ert-deftest core-elisp-tests-2-window-configurations () | ||
| 230 | "Test properties of window-configurations." | 216 | "Test properties of window-configurations." |
| 231 | (let ((wc (current-window-configuration))) | 217 | (let ((wc (current-window-configuration))) |
| 232 | (with-current-buffer (window-buffer (frame-selected-window)) | 218 | (with-current-buffer (window-buffer (frame-selected-window)) |
| @@ -235,40 +221,10 @@ | |||
| 235 | (set-window-configuration wc) | 221 | (set-window-configuration wc) |
| 236 | (should (or (not mark-active) (mark))))) | 222 | (should (or (not mark-active) (mark))))) |
| 237 | 223 | ||
| 238 | (ert-deftest core-elisp-tests-3-backquote () | 224 | ;; For variable binding tests, see src/data-tests.el. |
| 225 | (ert-deftest core-elisp-tests-2-backquote () | ||
| 239 | (should (eq 3 (eval ``,,'(+ 1 2) t)))) | 226 | (should (eq 3 (eval ``,,'(+ 1 2) t)))) |
| 240 | 227 | ||
| 241 | (defvar-local c-e-l 'foo) | ||
| 242 | (ert-deftest core-elisp-tests-4-toplevel-values () | ||
| 243 | (setq-default c-e-l 'foo) | ||
| 244 | (let ((c-e-l 'bar)) | ||
| 245 | (let ((c-e-l 'baz)) | ||
| 246 | (setq-default c-e-l 'bar) | ||
| 247 | (should (eq c-e-l 'bar)) | ||
| 248 | (should (eq (default-toplevel-value 'c-e-l) 'foo)) | ||
| 249 | (set-default-toplevel-value 'c-e-l 'baz) | ||
| 250 | (should (eq c-e-l 'bar)) | ||
| 251 | (should (eq (default-toplevel-value 'c-e-l) 'baz)))) | ||
| 252 | (let ((c-e-u 'foo)) | ||
| 253 | (should (condition-case _ | ||
| 254 | (default-toplevel-value 'c-e-u) | ||
| 255 | (void-variable t)))) | ||
| 256 | (with-temp-buffer | ||
| 257 | (setq-local c-e-l 'bar) | ||
| 258 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar)) | ||
| 259 | (let ((c-e-l 'baz)) | ||
| 260 | (let ((c-e-l 'quux)) | ||
| 261 | (setq-local c-e-l 'baz) | ||
| 262 | (should (eq c-e-l 'baz)) | ||
| 263 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar)) | ||
| 264 | (set-buffer-local-toplevel-value 'c-e-l 'foo) | ||
| 265 | (should (eq c-e-l 'baz)) | ||
| 266 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'foo))))) | ||
| 267 | (with-temp-buffer | ||
| 268 | (should (condition-case _ | ||
| 269 | (buffer-local-toplevel-value 'c-e-l) | ||
| 270 | (void-variable t))))) | ||
| 271 | |||
| 272 | ;; Test up-list and backward-up-list. | 228 | ;; Test up-list and backward-up-list. |
| 273 | (defun lisp-run-up-list-test (fn data start instructions) | 229 | (defun lisp-run-up-list-test (fn data start instructions) |
| 274 | (cl-labels ((posof (thing) | 230 | (cl-labels ((posof (thing) |
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 260bdb281bb..75be9856463 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -354,6 +354,19 @@ comparing the subr with a much slower Lisp implementation." | |||
| 354 | (setq-default binding-test-some-local 'new-default)) | 354 | (setq-default binding-test-some-local 'new-default)) |
| 355 | (should (eq binding-test-some-local 'some)))) | 355 | (should (eq binding-test-some-local 'some)))) |
| 356 | 356 | ||
| 357 | (defvar c-e-x) | ||
| 358 | (ert-deftest binding-test-defvar-in-let () | ||
| 359 | "Test some core Elisp rules." | ||
| 360 | (with-temp-buffer | ||
| 361 | ;; Check that when defvar is run within a let-binding, the toplevel default | ||
| 362 | ;; is properly initialized. | ||
| 363 | (should (equal (list (let ((c-e-x 1)) (defvar c-e-x 2) c-e-x) c-e-x) | ||
| 364 | '(1 2))) | ||
| 365 | (should (equal (list (let ((c-e-x 1)) | ||
| 366 | (defcustom c-e-x 2 "doc" :group 'blah :type 'integer) c-e-x) | ||
| 367 | c-e-x) | ||
| 368 | '(1 2))))) | ||
| 369 | |||
| 357 | (ert-deftest data-tests--let-buffer-local () | 370 | (ert-deftest data-tests--let-buffer-local () |
| 358 | (let ((blvar (make-symbol "blvar"))) | 371 | (let ((blvar (make-symbol "blvar"))) |
| 359 | (set-default blvar nil) | 372 | (set-default blvar nil) |
| @@ -396,6 +409,37 @@ comparing the subr with a much slower Lisp implementation." | |||
| 396 | (should (equal (default-value var) def))) | 409 | (should (equal (default-value var) def))) |
| 397 | ))))) | 410 | ))))) |
| 398 | 411 | ||
| 412 | (defvar-local c-e-l 'foo) | ||
| 413 | (ert-deftest binding-test-toplevel-values () | ||
| 414 | (setq-default c-e-l 'foo) | ||
| 415 | (let ((c-e-l 'bar)) | ||
| 416 | (let ((c-e-l 'baz)) | ||
| 417 | (setq-default c-e-l 'bar) | ||
| 418 | (should (eq c-e-l 'bar)) | ||
| 419 | (should (eq (default-toplevel-value 'c-e-l) 'foo)) | ||
| 420 | (set-default-toplevel-value 'c-e-l 'baz) | ||
| 421 | (should (eq c-e-l 'bar)) | ||
| 422 | (should (eq (default-toplevel-value 'c-e-l) 'baz)))) | ||
| 423 | (let ((c-e-u 'foo)) | ||
| 424 | (should (condition-case _ | ||
| 425 | (default-toplevel-value 'c-e-u) | ||
| 426 | (void-variable t)))) | ||
| 427 | (with-temp-buffer | ||
| 428 | (setq-local c-e-l 'bar) | ||
| 429 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar)) | ||
| 430 | (let ((c-e-l 'baz)) | ||
| 431 | (let ((c-e-l 'quux)) | ||
| 432 | (setq-local c-e-l 'baz) | ||
| 433 | (should (eq c-e-l 'baz)) | ||
| 434 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'bar)) | ||
| 435 | (set-buffer-local-toplevel-value 'c-e-l 'foo) | ||
| 436 | (should (eq c-e-l 'baz)) | ||
| 437 | (should (eq (buffer-local-toplevel-value 'c-e-l) 'foo))))) | ||
| 438 | (with-temp-buffer | ||
| 439 | (should (condition-case _ | ||
| 440 | (buffer-local-toplevel-value 'c-e-l) | ||
| 441 | (void-variable t))))) | ||
| 442 | |||
| 399 | (ert-deftest binding-test-makunbound () | 443 | (ert-deftest binding-test-makunbound () |
| 400 | "Tests of makunbound, from the manual." | 444 | "Tests of makunbound, from the manual." |
| 401 | (with-current-buffer binding-test-buffer-B | 445 | (with-current-buffer binding-test-buffer-B |