aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/read-print.scm76
1 files changed, 75 insertions, 1 deletions
diff --git a/tests/read-print.scm b/tests/read-print.scm
index e9ba1127d4..f915b7e2d2 100644
--- a/tests/read-print.scm
+++ b/tests/read-print.scm
@@ -19,7 +19,8 @@
(define-module (tests-style)
#:use-module (guix read-print)
#:use-module (guix gexp) ;for the reader extensions
- #:use-module (srfi srfi-64))
+ #:use-module (srfi srfi-64)
+ #:use-module (ice-9 match))
(define-syntax-rule (test-pretty-print str args ...)
"Test equality after a round-trip where STR is passed to
@@ -40,6 +41,35 @@
(call-with-input-string "(a . b)"
read-with-comments))
+(test-equal "read-with-comments: list with blank line"
+ `(list with ,(vertical-space 1) blank line)
+ (call-with-input-string "\
+(list with
+
+ blank line)\n"
+ read-with-comments))
+
+(test-equal "read-with-comments: list with multiple blank lines"
+ `(list with ,(comment ";multiple\n" #t)
+ ,(vertical-space 3) blank lines)
+ (call-with-input-string "\
+(list with ;multiple
+
+
+
+ blank lines)\n"
+ read-with-comments))
+
+(test-equal "read-with-comments: top-level blank lines"
+ (list (vertical-space 2) '(a b c) (vertical-space 2))
+ (call-with-input-string "
+
+(a b c)\n\n"
+ (lambda (port)
+ (list (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)")
@@ -181,6 +211,24 @@ mnopqrstuvwxyz.\")"
`(cons \"--without-any-problem\"
,flags)))")
+(test-pretty-print "\
+(vertical-space one:
+
+ two:
+
+
+ three:
+
+
+
+ end)")
+
+(test-pretty-print "\
+(vertical-space one
+
+ ;; Comment after blank line.
+ two)")
+
(test-equal "pretty-print-with-comments, canonicalize-comment"
"\
(list abc
@@ -206,4 +254,30 @@ mnopqrstuvwxyz.\")"
#:format-comment
canonicalize-comment)))))
+(test-equal "pretty-print-with-comments, canonicalize-vertical-space"
+ "\
+(list abc
+
+ def
+
+ ;; last one
+ ghi)"
+ (let ((sexp (call-with-input-string
+ "\
+(list abc
+
+
+
+ def
+
+
+;; last one
+ ghi)"
+ read-with-comments)))
+ (call-with-output-string
+ (lambda (port)
+ (pretty-print-with-comments port sexp
+ #:format-vertical-space
+ canonicalize-vertical-space)))))
+
(test-end)