aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-07-17 15:40:06 +0200
committerLudovic Courtès <ludo@gnu.org>2014-07-17 15:40:06 +0200
commit2cf0ea0dbbd5a43a62dadb81948ee29898585dd7 (patch)
tree742b2ea6f4f270f93dd1f0b2acda4ba14a5f806d /tests
parent8aaaae38a37f806a62284c6bce116586d8b66b87 (diff)
downloadgnu-guix-2cf0ea0dbbd5a43a62dadb81948ee29898585dd7.tar
gnu-guix-2cf0ea0dbbd5a43a62dadb81948ee29898585dd7.tar.gz
gexp: Gracefully handle printing of gexps with spliced references.
* guix/gexp.scm (write-gexp): Wrap 'write' call in 'false-if-exception'. * tests/gexp.scm ("printer", "printer vs. ungexp-splicing"): New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/gexp.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm
index b0ff1019e6..6d4885e44e 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -29,6 +29,7 @@
#:use-module (srfi srfi-64)
#:use-module (rnrs io ports)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:use-module (ice-9 popen))
;; Test the (guix gexp) module.
@@ -247,6 +248,23 @@
(return (and (zero? (close-pipe pipe))
(= (expt n 2) (string->number str)))))))
+(test-assert "printer"
+ (string-match "^#<gexp \\(string-append .*#<package coreutils.*\
+ \"/bin/uname\"\\) [[:xdigit:]]+>$"
+ (with-output-to-string
+ (lambda ()
+ (write
+ (gexp (string-append (ungexp coreutils)
+ "/bin/uname")))))))
+
+(test-assert "printer vs. ungexp-splicing"
+ (string-match "^#<gexp .* [[:xdigit:]]+>$"
+ (with-output-to-string
+ (lambda ()
+ ;; #~(begin #$@#~())
+ (write
+ (gexp (begin (ungexp-splicing (gexp ())))))))))
+
(test-equal "sugar"
'(gexp (foo (ungexp bar) (ungexp baz "out")
(ungexp (chbouib 42))