aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBjörn Lindström2024-06-11 19:49:55 +0200
committerEli Zaretskii2024-06-29 16:01:50 +0300
commit2a7a7c6f697ac9699dec8b09f1cd2051247b2b45 (patch)
tree34f054165f93ca4bccbed8af3b2baf188fc91bd4 /test
parentc4709d6bcdc93a3d28a3c252060dd3523560f455 (diff)
downloademacs-2a7a7c6f697ac9699dec8b09f1cd2051247b2b45.tar.gz
emacs-2a7a7c6f697ac9699dec8b09f1cd2051247b2b45.zip
Make whitespace.el's cleanup add missing final newline
* lisp/whitespace.el (whitespace-cleanup-region): If cleaning up at end of file, add missing newline if indicated by 'whitespace-style'. (Bug#71499) * etc/NEWS: Announce the change in behavior.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/whitespace-tests.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index 73c7e742ec5..bd35b3ac9f3 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -8,7 +8,6 @@
8;; it under the terms of the GNU General Public License as published by 8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or 9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version. 10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful, 11;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -94,6 +93,20 @@ buffer's content."
94 (should (equal (whitespace-tests--cleanup-string "a \n\t \n\n") 93 (should (equal (whitespace-tests--cleanup-string "a \n\t \n\n")
95 "a \n")))) 94 "a \n"))))
96 95
96(ert-deftest whitespace-cleanup-missing-newline-at-eof ()
97 (let ((whitespace-style '(empty missing-newline-at-eof)))
98 (should (equal (whitespace-tests--cleanup-string "")
99 ""))
100 (should (equal (whitespace-tests--cleanup-string "a")
101 "a\n"))
102 (should (equal (whitespace-tests--cleanup-string "a\n\t")
103 "a\n"))
104 (should (equal (whitespace-tests--cleanup-string "a\n\t ")
105 "a\n"))
106 (should (equal (whitespace-tests--cleanup-string "a\n\t ")
107 "a\n"))
108 (should (equal (whitespace-tests--cleanup-string "\n\t")
109 ""))))
97 110
98;; We cannot call whitespace-mode because it will do nothing in batch 111;; We cannot call whitespace-mode because it will do nothing in batch
99;; mode. So we call its innards instead. 112;; mode. So we call its innards instead.