diff options
| author | Tom Tromey <tom@tromey.com> | 2017-08-04 09:01:37 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-04 09:01:37 -0600 |
| commit | afeddec5a4755418cde1537364cfc30ae280354e (patch) | |
| tree | 24ce93dcd92458682eb66c7c02cc3a5a55303a3e /rust-mode-tests.el | |
| parent | 30a9d398fbdb88af16725248656956cb350c821d (diff) | |
| parent | 1d4a75f84865356a3cf6dbc1b0b32ec43496446e (diff) | |
| download | rust-mode-afeddec5a4755418cde1537364cfc30ae280354e.tar.gz | |
Merge pull request #224 from tromey/beginning-of-defun
Make rust-beginning-of-defun ignore comments and strings
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 7f1020f..de8a2cc 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1025,6 +1025,43 @@ All positions are position symbols found in `rust-test-positions-alist'." 'beginning-of-fn3 #'beginning-of-defun)) +(ert-deftest rust-beginning-of-defun-string-comment () + (let (fn-1 fn-2 p-1 p-2) + (with-temp-buffer + (rust-mode) + (insert "fn test1() { + let s=r#\" +fn test2(); +\"#;") + (setq p-1 (point)) + (setq fn-1 (1+ p-1)) + (insert " +fn test3() { + /* +fn test4();") + (setq p-2 (point)) + (insert "\n*/\n}\n") + (setq fn-2 (point)) + (insert "fn test5() { }") + + (goto-char p-1) + (beginning-of-defun) + (should (eq (point) (point-min))) + + (beginning-of-defun -2) + (should (eq (point) fn-2)) + + (goto-char p-2) + (beginning-of-defun) + (should (eq (point) fn-1)) + + (beginning-of-defun -1) + (should (eq (point) fn-2)) + + (goto-char (point-max)) + (beginning-of-defun 2) + (should (eq (point) fn-1))))) + (ert-deftest rust-end-of-defun-from-middle-of-fn () (rust-test-motion rust-test-motion-string |
