summaryrefslogtreecommitdiff
path: root/test/src/data-tests.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2018-03-23 11:29:06 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2018-03-23 11:29:06 -0400
commit3ddff080341580eb6fc18d907181e9cc2301f62d (patch)
tree935d45325c27bea24ea660b83b50fa308bc6421a /test/src/data-tests.el
parentcf3164523b32f01dbaad2c1364ecf2dcf8f22aa5 (diff)
downloademacs-3ddff080341580eb6fc18d907181e9cc2301f62d.tar.gz
Fix bug#30846, along with misc cleanups found along the way
* test/src/data-tests.el (data-tests-kill-all-local-variables): New test. * src/buffer.c (swap_out_buffer_local_variables): Remove. Fuse the body of its loop into that of reset_buffer_local_variables. (Fkill_buffer, Fkill_all_local_variables): Don't call it any more. (reset_buffer_local_variables): Make sure the buffer's local binding is swapped out before removing it from the alist (bug#30846). Call watchers before actually killing the var. * src/data.c (Fmake_local_variable): Simplify. Use swap_in_global_binding to swap out any local binding, instead of a mix of find_symbol_value followed by messing with where&found. Don't call swap_in_symval_forwarding since the currently swapped binding is never one we've modified. (Fkill_local_variable): Use swap_in_global_binding rather than messing with where&found to try and trick find_symbol_value into doing the same. * src/alloc.c (mark_localized_symbol): 'where' can't be a frame any more.
Diffstat (limited to 'test/src/data-tests.el')
-rw-r--r--test/src/data-tests.el19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 33b00d6c9ad..3cd537859fd 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -1,4 +1,4 @@
-;;; data-tests.el --- tests for src/data.c
+;;; data-tests.el --- tests for src/data.c -*- lexical-binding:t -*-
;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
@@ -499,3 +499,20 @@ comparing the subr with a much slower lisp implementation."
(remove-variable-watcher 'data-tests-lvar collect-watch-data)
(setq data-tests-lvar 6)
(should (null watch-data)))))
+
+(ert-deftest data-tests-kill-all-local-variables () ;bug#30846
+ (with-temp-buffer
+ (setq-local data-tests-foo1 1)
+ (setq-local data-tests-foo2 2)
+ (setq-local data-tests-foo3 3)
+ (let ((oldfoo2 nil))
+ (add-variable-watcher 'data-tests-foo2
+ (lambda (&rest _)
+ (setq oldfoo2 (bound-and-true-p data-tests-foo2))))
+ (kill-all-local-variables)
+ (should (equal oldfoo2 '2)) ;Watcher is run before changing the var.
+ (should (not (or (bound-and-true-p data-tests-foo1)
+ (bound-and-true-p data-tests-foo2)
+ (bound-and-true-p data-tests-foo3)))))))
+
+;;; data-tests.el ends here