diff options
| author | mrBliss <dewinant@gmail.com> | 2016-09-09 10:33:31 +0200 |
|---|---|---|
| committer | mrBliss <dewinant@gmail.com> | 2016-09-09 10:33:31 +0200 |
| commit | bec3d0c9b7e26016ea1b8c25616783955903aaf1 (patch) | |
| tree | a791dda5304c8fd5178a0ead4bea7457c1351567 /rust-mode-tests.el | |
| parent | a789a257c703d1e0041b6b193a41429124f90b44 (diff) | |
| download | rust-mode-bec3d0c9b7e26016ea1b8c25616783955903aaf1.tar.gz | |
Test #169
Before applying #169 the new test fails with a stack overflow, with #169
it passes.
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 17 |
1 files changed, 17 insertions, 0 deletions
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) |
