(define-module (tests-style)
#:use-module (guix read-print)
#:use-module (guix gexp) ;for the reader extensions
+ #:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-35)
#:use-module (srfi srfi-64)
#:use-module (ice-9 match))
\f
(test-begin "read-print")
+(test-assert "read-with-comments: missing closing paren"
+ (guard (c ((error? c) #t))
+ (call-with-input-string "(what is going on?"
+ read-with-comments)))
+
(test-equal "read-with-comments: dot notation"
(cons 'a 'b)
(call-with-input-string "(a . b)"
(let ((z (+ x y)))
(* z z)))")
+(test-pretty-print "\
+(case x
+ ((1)
+ 'one)
+ ((2)
+ 'two))")
+
+(test-pretty-print "\
+(cond
+ ((zero? x)
+ 'zero)
+ ((odd? x)
+ 'odd)
+ (else #f))")
+
(test-pretty-print "\
#~(string-append #$coreutils \"/bin/uname\")")
(lambda _
xyz))))")
+(test-pretty-print "\
+(string-append \"a\\tb\" \"\\n\")")
+
(test-pretty-print "\
(description \"abcdefghijkl
mnopqrstuvwxyz.\")"
(+ a b))))
(list x y z))")
+(test-pretty-print "\
+(begin
+ (chmod \"foo\" #o750)
+ (chmod port
+ (logand #o644
+ (lognot (umask))))
+ (logand #x7f xyz))")
+
(test-pretty-print "\
(substitute-keyword-arguments (package-arguments x)
((#:phases phases)
;; page break above
end)")
+(test-pretty-print "\
+(home-environment
+ (services
+ (list (service-type home-bash-service-type))))")
+
(test-pretty-print/sequence "\
;;; This is a top-level comment.
#:format-vertical-space
canonicalize-vertical-space)))))
+(test-equal "pretty-print-with-comments, multi-line comment"
+ "\
+(list abc
+ ;; This comment spans
+ ;; two lines.
+ def)"
+ (call-with-output-string
+ (lambda (port)
+ (pretty-print-with-comments port
+ `(list abc ,(comment "\
+;; This comment spans\n
+;; two lines.\n")
+ def)))))
+
(test-end)