aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/eval-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 281d959b530..0c242913e7a 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -139,4 +139,34 @@ crash/abort/malloc assert failure on the next test."
139 (defvaralias 'eval-tests--foo-alias 'eval-tests--foo) 139 (defvaralias 'eval-tests--foo-alias 'eval-tests--foo)
140 'no-warning))))) 140 'no-warning)))))
141 141
142(ert-deftest eval-tests-byte-code-being-evaluated-is-protected-from-gc ()
143 "Regression test for Bug#33014.
144Check that byte-compiled objects being executed by exec-byte-code
145are found on the stack and therefore not garbage collected."
146 (should (string= (eval-tests-33014-func)
147 "before after: ok foo: (e) bar: (a b c d e) baz: a bop: c")))
148
149(defvar eval-tests-33014-var "ok")
150(defun eval-tests-33014-func ()
151 "A function which has a non-trivial constants vector when byte-compiled."
152 (let ((result "before "))
153 (eval-tests-33014-redefine)
154 (garbage-collect)
155 (setq result (concat result (format "after: %s" eval-tests-33014-var)))
156 (let ((vals '(0 1 2 3))
157 (things '(a b c d e)))
158 (dolist (val vals)
159 (setq result
160 (concat result " "
161 (cond
162 ((= val 0) (format "foo: %s" (last things)))
163 ((= val 1) (format "bar: %s" things))
164 ((= val 2) (format "baz: %s" (car things)))
165 (t (format "bop: %s" (nth 2 things))))))))
166 result))
167
168(defun eval-tests-33014-redefine ()
169 "Remove the Lisp reference to the byte-compiled object."
170 (setf (symbol-function #'eval-tests-33014-func) nil))
171
142;;; eval-tests.el ends here 172;;; eval-tests.el ends here