]> code.delx.au - gnu-emacs/blobdiff - test/lisp/simple-tests.el
Make ‘delete-trailing-whitespace’ delete spaces after form feed
[gnu-emacs] / test / lisp / simple-tests.el
index 40cd1d29498f95d4fcbacd4ded021bb18c48dfb1..2722544446d1cfb755e7f6d2c2219d3fab732ed4 100644 (file)
 
 \f
 ;;; `delete-trailing-whitespace'
-(ert-deftest simple-delete-trailing-whitespace ()
+(ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
   "Test bug#21766: delete-whitespace sometimes deletes non-whitespace."
   (defvar python-indent-guess-indent-offset)  ; to avoid a warning
   (let ((python (featurep 'python))
                           "\n"
                           "\n"))
           (delete-trailing-whitespace)
-          (should (equal (count-lines (point-min) (point-max)) 3)))
+          (should (string-equal (buffer-string)
+                                (concat "query = \"\"\"WITH filtered AS\n"
+                                        "WHERE\n"
+                                        "\"\"\".format(fv_)\n"))))
       ;; Let's clean up if running interactive
       (unless (or noninteractive python)
         (unload-feature 'python)))))
 
+(ert-deftest simple-delete-trailing-whitespace--formfeeds ()
+  "Test formfeeds are not deleted but whitespace past them is."
+  (with-temp-buffer
+    (with-syntax-table (make-syntax-table)
+      (modify-syntax-entry ?\f " ")     ; Make sure \f is whitespace
+      (insert " \f \n \f \f \n\nlast\n")
+      (delete-trailing-whitespace)
+      (should (string-equal (buffer-string) " \f\n \f \f\n\nlast\n"))
+      (should (equal ?\s (char-syntax ?\f))))))
+
 
 ;;; auto-boundary tests
 (ert-deftest undo-auto-boundary-timer ()