summaryrefslogtreecommitdiff
path: root/tests/read-print.scm
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/read-print.scm
parentf687e27e0385c7f9bab8d967293061158fc3f504 (diff)
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/read-print.scm')
-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 f915b7e2d21..70be7754f8a 100644
--- a/tests/read-print.scm
+++ b/tests/read-print.scm
@@ -70,6 +70,21 @@
70 (read-with-comments port) 70 (read-with-comments port)
71 (read-with-comments port))))) 71 (read-with-comments port)))))
72 72
73(test-equal "read-with-comments: top-level page break"
74 (list (comment ";; Begin.\n") (vertical-space 1)
75 (page-break)
76 (comment ";; End.\n"))
77 (call-with-input-string "\
78;; Begin.
79
80
81;; End.\n"
82 (lambda (port)
83 (list (read-with-comments port)
84 (read-with-comments port)
85 (read-with-comments port)
86 (read-with-comments port)))))
87
73(test-pretty-print "(list 1 2 3 4)") 88(test-pretty-print "(list 1 2 3 4)")
74(test-pretty-print "((a . 1) (b . 2))") 89(test-pretty-print "((a . 1) (b . 2))")
75(test-pretty-print "(a b c . boom)") 90(test-pretty-print "(a b c . boom)")
@@ -229,6 +244,13 @@ mnopqrstuvwxyz.\")"
229 ;; Comment after blank line. 244 ;; Comment after blank line.
230 two)") 245 two)")
231 246
247(test-pretty-print "\
248(begin
249 break
250
251 ;; page break above
252 end)")
253
232(test-equal "pretty-print-with-comments, canonicalize-comment" 254(test-equal "pretty-print-with-comments, canonicalize-comment"
233 "\ 255 "\
234(list abc 256(list abc