aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorNoam Postavsky2018-06-03 12:55:37 -0400
committerNoam Postavsky2018-06-03 12:55:40 -0400
commit9a14b4d1ce84e5e0739572729670b8f10d234097 (patch)
tree880aa4dab830e5e7699e6eace5c0a1097a091baa /test/src
parent5fa73a7d98040f749f4cd45cfa40cf3c1c8cc2e3 (diff)
parented962f2b8a2f63c7dbf31ec5df3c915703dd571d (diff)
downloademacs-9a14b4d1ce84e5e0739572729670b8f10d234097.tar.gz
emacs-9a14b4d1ce84e5e0739572729670b8f10d234097.zip
; Merge: backports from master
Diffstat (limited to 'test/src')
-rw-r--r--test/src/data-tests.el19
-rw-r--r--test/src/editfns-tests.el51
2 files changed, 69 insertions, 1 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index dda1278b6d4..91463db113c 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -1,4 +1,4 @@
1;;; data-tests.el --- tests for src/data.c 1;;; data-tests.el --- tests for src/data.c -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2013-2018 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
4 4
@@ -484,3 +484,20 @@ comparing the subr with a much slower lisp implementation."
484 (remove-variable-watcher 'data-tests-lvar collect-watch-data) 484 (remove-variable-watcher 'data-tests-lvar collect-watch-data)
485 (setq data-tests-lvar 6) 485 (setq data-tests-lvar 6)
486 (should (null watch-data))))) 486 (should (null watch-data)))))
487
488(ert-deftest data-tests-kill-all-local-variables () ;bug#30846
489 (with-temp-buffer
490 (setq-local data-tests-foo1 1)
491 (setq-local data-tests-foo2 2)
492 (setq-local data-tests-foo3 3)
493 (let ((oldfoo2 nil))
494 (add-variable-watcher 'data-tests-foo2
495 (lambda (&rest _)
496 (setq oldfoo2 (bound-and-true-p data-tests-foo2))))
497 (kill-all-local-variables)
498 (should (equal oldfoo2 '2)) ;Watcher is run before changing the var.
499 (should (not (or (bound-and-true-p data-tests-foo1)
500 (bound-and-true-p data-tests-foo2)
501 (bound-and-true-p data-tests-foo3)))))))
502
503;;; data-tests.el ends here
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index b72f37d1f01..714e92e5053 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -247,4 +247,55 @@
247 (buffer-string) 247 (buffer-string)
248 "foo bar baz qux")))))) 248 "foo bar baz qux"))))))
249 249
250(ert-deftest delete-region-undo-markers-1 ()
251 "Make sure we don't end up with freed markers reachable from Lisp."
252 ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30931#40
253 (with-temp-buffer
254 (insert "1234567890")
255 (setq buffer-undo-list nil)
256 (narrow-to-region 2 5)
257 ;; `save-restriction' in a narrowed buffer creates two markers
258 ;; representing the current restriction.
259 (save-restriction
260 (widen)
261 ;; Any markers *within* the deleted region are put onto the undo
262 ;; list.
263 (delete-region 1 6))
264 ;; (princ (format "%S" buffer-undo-list) #'external-debugging-output)
265 ;; `buffer-undo-list' is now
266 ;; (("12345" . 1) (#<temp-marker1> . -1) (#<temp-marker2> . 1))
267 ;;
268 ;; If temp-marker1 or temp-marker2 are freed prematurely, calling
269 ;; `type-of' on them will cause Emacs to abort. Calling
270 ;; `garbage-collect' will also abort if it finds any reachable
271 ;; freed objects.
272 (should (eq (type-of (car (nth 1 buffer-undo-list))) 'marker))
273 (should (eq (type-of (car (nth 2 buffer-undo-list))) 'marker))
274 (garbage-collect)))
275
276(ert-deftest delete-region-undo-markers-2 ()
277 "Make sure we don't end up with freed markers reachable from Lisp."
278 ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30931#55
279 (with-temp-buffer
280 (insert "1234567890")
281 (setq buffer-undo-list nil)
282 ;; signal_before_change creates markers delimiting a change
283 ;; region.
284 (let ((before-change-functions
285 (list (lambda (beg end)
286 (delete-region (1- beg) (1+ end))))))
287 (delete-region 2 5))
288 ;; (princ (format "%S" buffer-undo-list) #'external-debugging-output)
289 ;; `buffer-undo-list' is now
290 ;; (("678" . 1) ("12345" . 1) (#<marker in no buffer> . -1)
291 ;; (#<temp-marker1> . -1) (#<temp-marker2> . -4))
292 ;;
293 ;; If temp-marker1 or temp-marker2 are freed prematurely, calling
294 ;; `type-of' on them will cause Emacs to abort. Calling
295 ;; `garbage-collect' will also abort if it finds any reachable
296 ;; freed objects.
297 (should (eq (type-of (car (nth 3 buffer-undo-list))) 'marker))
298 (should (eq (type-of (car (nth 4 buffer-undo-list))) 'marker))
299 (garbage-collect)))
300
250;;; editfns-tests.el ends here 301;;; editfns-tests.el ends here