packages: Raise an exception for invalid 'license' values.
[jackhill/guix/guix.git] / tests / read-print.scm
index e3f2319..ea52a52 100644 (file)
@@ -19,6 +19,8 @@
 (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))
 
@@ -46,6 +48,11 @@ expressions."
 \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)"
@@ -141,6 +148,21 @@ expressions."
   (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\")")
 
@@ -164,6 +186,9 @@ expressions."
               (lambda _
                 xyz))))")
 
+(test-pretty-print "\
+(string-append \"a\\tb\" \"\\n\")")
+
 (test-pretty-print "\
 (description \"abcdefghijkl
 mnopqrstuvwxyz.\")"
@@ -225,6 +250,14 @@ 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)
@@ -261,6 +294,11 @@ mnopqrstuvwxyz.\")"
   ;; 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.
 
@@ -341,4 +379,18 @@ mnopqrstuvwxyz.\")"
                                     #: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)