From 077324a16fd6c7d2307bfa52a9863ca25cfc6a52 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 2 Aug 2022 15:29:55 +0200 Subject: read-print: Recognize page breaks. * guix/read-print.scm (, page-break?, page-break) (char-set:whitespace-sans-page-break): New variables. (space?): New procedure. (read-vertical-space): Use it. (read-until-end-of-line): New procedure. (read-with-comments): Add #\page case. (pretty-print-with-comments): Add 'page-break?' case. * tests/read-print.scm ("read-with-comments: top-level page break"): New test. Add round-trip test with page break within an sexp. --- tests/read-print.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/read-print.scm b/tests/read-print.scm index f915b7e2d2..70be7754f8 100644 --- a/tests/read-print.scm +++ b/tests/read-print.scm @@ -70,6 +70,21 @@ (read-with-comments port) (read-with-comments port))))) +(test-equal "read-with-comments: top-level page break" + (list (comment ";; Begin.\n") (vertical-space 1) + (page-break) + (comment ";; End.\n")) + (call-with-input-string "\ +;; Begin. + + +;; End.\n" + (lambda (port) + (list (read-with-comments port) + (read-with-comments port) + (read-with-comments port) + (read-with-comments port))))) + (test-pretty-print "(list 1 2 3 4)") (test-pretty-print "((a . 1) (b . 2))") (test-pretty-print "(a b c . boom)") @@ -229,6 +244,13 @@ mnopqrstuvwxyz.\")" ;; Comment after blank line. two)") +(test-pretty-print "\ +(begin + break + + ;; page break above + end)") + (test-equal "pretty-print-with-comments, canonicalize-comment" "\ (list abc -- cgit v1.2.3