summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2017-11-11 23:44:52 +0000
committerJoão Távora <joaotavora@gmail.com>2017-11-11 23:44:52 +0000
commite286b3381fa1be64174832560da963b1c0191640 (patch)
tree868f64028e662664e8d47d21027213f812f20d68 /test
parent9533d76b0b5bfe2df1cccc55a92c2545b1de4e2b (diff)
downloademacs-e286b3381fa1be64174832560da963b1c0191640.tar.gz
Fix more flymake-diag-region eob corner cases and add tests (bug#29201)
* lisp/progmodes/flymake.el (flymake-diag-region): Correct more eob corner cases. * test/lisp/progmodes/flymake-tests.el (eob-region-and-trailing-newline): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/flymake-tests.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/lisp/progmodes/flymake-tests.el b/test/lisp/progmodes/flymake-tests.el
index 05214e7a927..bc194b69ccb 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -333,6 +333,38 @@ SEVERITY-PREDICATE is used to setup
(should-error (flymake-goto-prev-error nil nil t))
)))))
+(ert-deftest eob-region-and-trailing-newline ()
+ "`flymake-diag-region' at eob with varying trailing newlines."
+ (cl-flet ((diag-region-substring
+ (line col)
+ (pcase-let
+ ((`(,a . ,b) (flymake-diag-region (current-buffer) line col)))
+ (buffer-substring a b))))
+ (with-temp-buffer
+ (insert "beg\nmmm\nend")
+ (should (equal
+ (diag-region-substring 3 3)
+ "d"))
+ (should (equal
+ (diag-region-substring 3 nil)
+ "end"))
+ (insert "\n")
+ (should (equal
+ (diag-region-substring 4 1)
+ "end"))
+ (should (equal
+ (diag-region-substring 4 nil)
+ "end"))
+ (insert "\n")
+ (should (equal
+ (diag-region-substring 5 1)
+ "\n"))
+ (should (equal
+ (diag-region-substring 5 nil)
+ "\n")))))
+
+
+
(provide 'flymake-tests)
;;; flymake.el ends here