Skip to content

Commit

Permalink
Merge pull request #488 from jimblandy/fill-variables
Browse files Browse the repository at this point in the history
Establish more-controlled environment for fill-paragraph tests.
  • Loading branch information
jimblandy authored Jan 15, 2023
2 parents c12348e + 673a322 commit 22fff6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rust-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
(should (rust-compare-code-after-manip
original point-pos manip-func expected (buffer-string)))))

(defmacro rust-test-with-standard-fill-settings (&rest body)
(declare (indent defun))
`(let ((fill-column rust-test-fill-column)
(sentence-end-double-space t)
(colon-double-space nil))
,@body))

(defun rust-test-fill-paragraph (unfilled expected &optional start-pos end-pos)
"We're going to run through many scenarios here--the point should be able to be anywhere from the start-pos (defaults to 1) through end-pos (defaults to the length of what was passed in) and (fill-paragraph) should return the same result. It should also work with fill-region from start-pos to end-pos.
Expand All @@ -78,15 +85,15 @@ Also, the result should be the same regardless of whether the code is at the beg
(concat padding-beginning unfilled padding-end)
pos
(lambda ()
(let ((fill-column rust-test-fill-column))
(rust-test-with-standard-fill-settings
(fill-paragraph)))
(concat padding-beginning expected padding-end)))))
;; In addition to all the fill-paragraph tests, check that it works using fill-region
(rust-test-manip-code
unfilled
start-pos
(lambda ()
(let ((fill-column rust-test-fill-column))
(rust-test-with-standard-fill-settings
(fill-region start-pos end-pos)))
expected)
))
Expand Down

0 comments on commit 22fff6a

Please sign in to comment.