summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-08-02 15:29:55 +0200
committerLudovic Courtès <ludo@gnu.org>2022-08-08 11:22:32 +0200
commit077324a16fd6c7d2307bfa52a9863ca25cfc6a52 (patch)
tree507f6aeeaa99a99c0e5e68d6e307766897d05230 /tests
parentf687e27e0385c7f9bab8d967293061158fc3f504 (diff)
downloadguix-077324a16fd6c7d2307bfa52a9863ca25cfc6a52.tar.gz
read-print: Recognize page breaks.
* guix/read-print.scm (<page-break>, 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.
Diffstat (limited to 'tests')
-rw-r--r--tests/read-print.scm22
1 files changed, 22 insertions, 0 deletions
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