summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/pp-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/emacs-lisp/pp-tests.el')
-rw-r--r--test/lisp/emacs-lisp/pp-tests.el49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/pp-tests.el b/test/lisp/emacs-lisp/pp-tests.el
index b663fb365a8..7606183d645 100644
--- a/test/lisp/emacs-lisp/pp-tests.el
+++ b/test/lisp/emacs-lisp/pp-tests.el
@@ -36,4 +36,53 @@
(ert-deftest test-indentation ()
(ert-test-erts-file (ert-resource-file "code-formats.erts")))
+(defun pp-tests--dimensions ()
+ (save-excursion
+ (let ((width 0)
+ (height 0))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (end-of-line)
+ (setq height (1+ height))
+ (setq width (max width (current-column)))
+ (forward-char 1))
+ (cons width height))))
+
+(ert-deftest pp-tests--cut-before ()
+ (with-temp-buffer
+ (lisp-data-mode)
+ (pp '(1 (quite-a-long-package-name
+ . [(0 10 0) ((avy (0 5 0))) "Quickly switch windows." tar
+ ((:url . "https://github.com/abo-abo/ace-window")
+ (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com")
+ (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com"))
+ (:keywords "window" "location"))]))
+ (current-buffer))
+ ;; (message "Filled:\n%s" (buffer-string))
+ (let ((dimensions (pp-tests--dimensions)))
+ (should (< (car dimensions) 80))
+ (should (< (cdr dimensions) 8)))
+ (goto-char (point-min))
+ (while (search-forward "." nil t)
+ (should (not (eolp))))))
+
+(ert-deftest pp-tests--sanity ()
+ (with-temp-buffer
+ (lisp-data-mode)
+ (let ((testdata "(a b c #1=#[0 \"\" [] 0] #s(foo #1# bar))"))
+ (let ((res (car (read-from-string testdata))))
+ (dotimes (i (length testdata))
+ (erase-buffer)
+ (insert testdata)
+ (let ((fill-column i))
+ (pp-fill (point-min) (point-max))
+ (goto-char (point-min))
+ (condition-case err
+ (should (equal (read (current-buffer)) res))
+ (invalid-read-syntax
+ (message "Invalid fill result with i=%d:\n%s"
+ i (buffer-string))
+ (signal (car err) (cdr err))
+ ))))))))
+
;;; pp-tests.el ends here.