aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/data-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/data-tests.el')
-rw-r--r--test/src/data-tests.el50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index ed092039078..1312683c848 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -345,6 +345,25 @@ comparing the subr with a much slower lisp implementation."
345 (setq-default binding-test-some-local 'new-default)) 345 (setq-default binding-test-some-local 'new-default))
346 (should (eq binding-test-some-local 'some)))) 346 (should (eq binding-test-some-local 'some))))
347 347
348(ert-deftest data-tests--let-buffer-local ()
349 (let ((blvar (make-symbol "blvar")))
350 (set-default blvar nil)
351 (make-variable-buffer-local blvar)
352
353 (dolist (var (list blvar 'left-margin))
354 (let ((def (default-value var)))
355 (with-temp-buffer
356 (should (equal def (symbol-value var)))
357 (cl-progv (list var) (list 42)
358 (should (equal (symbol-value var) 42))
359 (should (equal (default-value var) (symbol-value var)))
360 (set var 123)
361 (should (equal (symbol-value var) 123))
362 (should (equal (default-value var) (symbol-value var)))) ;bug#44733
363 (should (equal (symbol-value var) def))
364 (should (equal (default-value var) (symbol-value var))))
365 (should (equal (default-value var) def))))))
366
348(ert-deftest binding-test-makunbound () 367(ert-deftest binding-test-makunbound ()
349 "Tests of makunbound, from the manual." 368 "Tests of makunbound, from the manual."
350 (with-current-buffer binding-test-buffer-B 369 (with-current-buffer binding-test-buffer-B
@@ -381,6 +400,37 @@ comparing the subr with a much slower lisp implementation."
381 "Test setting a keyword to itself" 400 "Test setting a keyword to itself"
382 (with-no-warnings (should (setq :keyword :keyword)))) 401 (with-no-warnings (should (setq :keyword :keyword))))
383 402
403(ert-deftest data-tests--set-default-per-buffer ()
404 :expected-result t ;; Not fixed yet!
405 ;; FIXME: Performance tests are inherently unreliable.
406 ;; Using wall-clock time makes it even worse, so don't bother unless
407 ;; we have the primitive to measure cpu-time.
408 (skip-unless (fboundp 'current-cpu-time))
409 ;; Test performance of set-default on DEFVAR_PER_BUFFER variables.
410 ;; More specifically, test the problem seen in bug#41029 where setting
411 ;; the default value of a variable takes time proportional to the
412 ;; number of buffers.
413 (let* ((fun #'error)
414 (test (lambda ()
415 (with-temp-buffer
416 (let ((st (car (current-cpu-time))))
417 (dotimes (_ 1000)
418 (let ((case-fold-search 'data-test))
419 ;; Use an indirection through a mutable var
420 ;; to try and make sure the byte-compiler
421 ;; doesn't optimize away the let bindings.
422 (funcall fun)))
423 ;; FIXME: Handle the wraparound, if any.
424 (- (car (current-cpu-time)) st)))))
425 (_ (setq fun #'ignore))
426 (time1 (funcall test))
427 (bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
428 (make-list 1000 nil)))
429 (time2 (funcall test)))
430 (mapc #'kill-buffer bufs)
431 ;; Don't divide one time by the other since they may be 0.
432 (should (< time2 (* time1 5)))))
433
384;; More tests to write - 434;; More tests to write -
385;; kill-local-variable 435;; kill-local-variable
386;; defconst; can modify 436;; defconst; can modify