From bec3d0c9b7e26016ea1b8c25616783955903aaf1 Mon Sep 17 00:00:00 2001 From: mrBliss Date: Fri, 9 Sep 2016 10:33:31 +0200 Subject: Test #169 Before applying #169 the new test fails with a stack overflow, with #169 it passes. --- rust-mode-tests.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'rust-mode-tests.el') diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 3c3ba03..35a1cbd 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1162,6 +1162,23 @@ All positions are position symbols found in `rust-test-positions-alist'." 'nonblank-line-indented-already-middle-target #'indent-for-tab-command)) +(ert-deftest no-stack-overflow-in-rust-rewind-irrelevant () + (with-temp-buffer + (rust-mode) + (insert "fn main() {\n let x = 1;") + ;; Insert 150 separate comments on the same line + (dotimes (i 150) + (insert "/* foo */ ")) + ;; Rewinding from the last commment to the end of the let needs at least + ;; 150 iterations, but if we limit the stack depth to 100 (this appears to + ;; be some minimum), a recursive function would overflow, throwing an + ;; error. + (let ((max-lisp-eval-depth 100)) + (rust-rewind-irrelevant) + ;; Only a non-stack overflowing function would make it this far. Also + ;; check that we rewound till after the ; + (should (= (char-before) ?\;))))) + (defun rust-test-fontify-string (str) (with-temp-buffer (rust-mode) -- cgit v1.2.3