diff options
| author | Gemini Lasswell | 2018-10-30 21:15:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-10-30 21:17:34 -0700 |
| commit | c3cf85b1c186e13c2d588aa35ffa57981ca481d7 (patch) | |
| tree | 335edbb7373db6f5a0b058c8aba55b4bfac483ad /test/src | |
| parent | 1ad2903a48b682985a2bd0709ec05f67a1351a8e (diff) | |
| download | emacs-c3cf85b1c186e13c2d588aa35ffa57981ca481d7.tar.gz emacs-c3cf85b1c186e13c2d588aa35ffa57981ca481d7.zip | |
Add regression test for Bug#33014
Backport from master.
* test/src/eval-tests.el:
(eval-tests-byte-code-being-evaluated-is-protected-from-gc): New test.
(eval-tests-33014-var): New variable.
(eval-tests-33014-func, eval-tests-33014-redefine): New functions.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/eval-tests.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index e68fd136113..eeb98b09948 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -99,4 +99,34 @@ crash/abort/malloc assert failure on the next test." | |||
| 99 | (signal-hook-function #'ignore)) | 99 | (signal-hook-function #'ignore)) |
| 100 | (should-error (eval-tests--exceed-specbind-limit)))) | 100 | (should-error (eval-tests--exceed-specbind-limit)))) |
| 101 | 101 | ||
| 102 | (ert-deftest eval-tests-byte-code-being-evaluated-is-protected-from-gc () | ||
| 103 | "Regression test for Bug#33014. | ||
| 104 | Check that byte-compiled objects being executed by exec-byte-code | ||
| 105 | are found on the stack and therefore not garbage collected." | ||
| 106 | (should (string= (eval-tests-33014-func) | ||
| 107 | "before after: ok foo: (e) bar: (a b c d e) baz: a bop: c"))) | ||
| 108 | |||
| 109 | (defvar eval-tests-33014-var "ok") | ||
| 110 | (defun eval-tests-33014-func () | ||
| 111 | "A function which has a non-trivial constants vector when byte-compiled." | ||
| 112 | (let ((result "before ")) | ||
| 113 | (eval-tests-33014-redefine) | ||
| 114 | (garbage-collect) | ||
| 115 | (setq result (concat result (format "after: %s" eval-tests-33014-var))) | ||
| 116 | (let ((vals '(0 1 2 3)) | ||
| 117 | (things '(a b c d e))) | ||
| 118 | (dolist (val vals) | ||
| 119 | (setq result | ||
| 120 | (concat result " " | ||
| 121 | (cond | ||
| 122 | ((= val 0) (format "foo: %s" (last things))) | ||
| 123 | ((= val 1) (format "bar: %s" things)) | ||
| 124 | ((= val 2) (format "baz: %s" (car things))) | ||
| 125 | (t (format "bop: %s" (nth 2 things)))))))) | ||
| 126 | result)) | ||
| 127 | |||
| 128 | (defun eval-tests-33014-redefine () | ||
| 129 | "Remove the Lisp reference to the byte-compiled object." | ||
| 130 | (setf (symbol-function #'eval-tests-33014-func) nil)) | ||
| 131 | |||
| 102 | ;;; eval-tests.el ends here | 132 | ;;; eval-tests.el ends here |