tests: Add an indirection for white-box testing.
[jackhill/guix/guix.git] / tests / gexp.scm
CommitLineData
21b679f6 1;;; GNU Guix --- Functional package management for GNU
462a3fa3 2;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
21b679f6
LC
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (test-gexp)
20 #:use-module (guix store)
21 #:use-module (guix monads)
22 #:use-module (guix gexp)
23 #:use-module (guix derivations)
79c0c8cd 24 #:use-module (guix packages)
c1bc358f 25 #:use-module (guix tests)
21b679f6
LC
26 #:use-module (gnu packages)
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (srfi srfi-1)
c8351d9a 30 #:use-module (srfi srfi-34)
21b679f6
LC
31 #:use-module (srfi srfi-64)
32 #:use-module (rnrs io ports)
33 #:use-module (ice-9 match)
2cf0ea0d 34 #:use-module (ice-9 regex)
21b679f6
LC
35 #:use-module (ice-9 popen))
36
37;; Test the (guix gexp) module.
38
39(define %store
c1bc358f 40 (open-connection-for-tests))
21b679f6
LC
41
42;; For white-box testing.
1f976033
LC
43(define (gexp-inputs x)
44 ((@@ (guix gexp) gexp-inputs) x))
45(define (gexp-native-inputs x)
46 ((@@ (guix gexp) gexp-native-inputs) x))
47(define (gexp-outputs x)
48 ((@@ (guix gexp) gexp-outputs) x))
49(define (gexp->sexp . x)
50 (apply (@@ (guix gexp) gexp->sexp) x))
21b679f6 51
667b2508 52(define* (gexp->sexp* exp #:optional target)
68a61e9f 53 (run-with-store %store (gexp->sexp exp
68a61e9f 54 #:target target)
c1bc358f 55 #:guile-for-build (%guile-for-build)))
21b679f6
LC
56
57(define-syntax-rule (test-assertm name exp)
58 (test-assert name
59 (run-with-store %store exp
c1bc358f 60 #:guile-for-build (%guile-for-build))))
21b679f6
LC
61
62\f
63(test-begin "gexp")
64
65(test-equal "no refs"
66 '(display "hello!")
67 (let ((exp (gexp (display "hello!"))))
68 (and (gexp? exp)
69 (null? (gexp-inputs exp))
70 (gexp->sexp* exp))))
71
72(test-equal "unquote"
73 '(display `(foo ,(+ 2 3)))
74 (let ((exp (gexp (display `(foo ,(+ 2 3))))))
75 (and (gexp? exp)
76 (null? (gexp-inputs exp))
77 (gexp->sexp* exp))))
78
79(test-assert "one input package"
80 (let ((exp (gexp (display (ungexp coreutils)))))
81 (and (gexp? exp)
82 (match (gexp-inputs exp)
83 (((p "out"))
84 (eq? p coreutils)))
85 (equal? `(display ,(derivation->output-path
86 (package-derivation %store coreutils)))
87 (gexp->sexp* exp)))))
88
79c0c8cd
LC
89(test-assert "one input origin"
90 (let ((exp (gexp (display (ungexp (package-source coreutils))))))
91 (and (gexp? exp)
92 (match (gexp-inputs exp)
93 (((o "out"))
94 (eq? o (package-source coreutils))))
95 (equal? `(display ,(derivation->output-path
96 (package-source-derivation
97 %store (package-source coreutils))))
98 (gexp->sexp* exp)))))
99
21b679f6
LC
100(test-assert "same input twice"
101 (let ((exp (gexp (begin
102 (display (ungexp coreutils))
103 (display (ungexp coreutils))))))
104 (and (gexp? exp)
105 (match (gexp-inputs exp)
106 (((p "out"))
107 (eq? p coreutils)))
108 (let ((e `(display ,(derivation->output-path
109 (package-derivation %store coreutils)))))
110 (equal? `(begin ,e ,e) (gexp->sexp* exp))))))
111
112(test-assert "two input packages, one derivation, one file"
113 (let* ((drv (build-expression->derivation
114 %store "foo" 'bar
115 #:guile-for-build (package-derivation %store %bootstrap-guile)))
116 (txt (add-text-to-store %store "foo" "Hello, world!"))
117 (exp (gexp (begin
118 (display (ungexp coreutils))
119 (display (ungexp %bootstrap-guile))
120 (display (ungexp drv))
121 (display (ungexp txt))))))
122 (define (match-input thing)
123 (match-lambda
124 ((drv-or-pkg _ ...)
125 (eq? thing drv-or-pkg))))
126
127 (and (gexp? exp)
128 (= 4 (length (gexp-inputs exp)))
129 (every (lambda (input)
130 (find (match-input input) (gexp-inputs exp)))
131 (list drv coreutils %bootstrap-guile txt))
132 (let ((e0 `(display ,(derivation->output-path
133 (package-derivation %store coreutils))))
134 (e1 `(display ,(derivation->output-path
135 (package-derivation %store %bootstrap-guile))))
136 (e2 `(display ,(derivation->output-path drv)))
137 (e3 `(display ,txt)))
138 (equal? `(begin ,e0 ,e1 ,e2 ,e3) (gexp->sexp* exp))))))
139
667b2508
LC
140(test-assert "ungexp + ungexp-native"
141 (let* ((exp (gexp (list (ungexp-native %bootstrap-guile)
142 (ungexp coreutils)
143 (ungexp-native glibc)
144 (ungexp binutils))))
145 (target "mips64el-linux")
146 (guile (derivation->output-path
147 (package-derivation %store %bootstrap-guile)))
148 (cu (derivation->output-path
149 (package-cross-derivation %store coreutils target)))
150 (libc (derivation->output-path
151 (package-derivation %store glibc)))
152 (bu (derivation->output-path
153 (package-cross-derivation %store binutils target))))
154 (and (lset= equal?
155 `((,%bootstrap-guile "out") (,glibc "out"))
156 (gexp-native-inputs exp))
157 (lset= equal?
158 `((,coreutils "out") (,binutils "out"))
159 (gexp-inputs exp))
160 (equal? `(list ,guile ,cu ,libc ,bu)
161 (gexp->sexp* exp target)))))
162
21b679f6
LC
163(test-assert "input list"
164 (let ((exp (gexp (display
165 '(ungexp (list %bootstrap-guile coreutils)))))
166 (guile (derivation->output-path
167 (package-derivation %store %bootstrap-guile)))
168 (cu (derivation->output-path
169 (package-derivation %store coreutils))))
170 (and (lset= equal?
171 `((,%bootstrap-guile "out") (,coreutils "out"))
172 (gexp-inputs exp))
173 (equal? `(display '(,guile ,cu))
174 (gexp->sexp* exp)))))
175
667b2508
LC
176(test-assert "input list + ungexp-native"
177 (let* ((target "mips64el-linux")
178 (exp (gexp (display
179 (cons '(ungexp-native (list %bootstrap-guile coreutils))
180 '(ungexp (list glibc binutils))))))
181 (guile (derivation->output-path
182 (package-derivation %store %bootstrap-guile)))
183 (cu (derivation->output-path
184 (package-derivation %store coreutils)))
185 (xlibc (derivation->output-path
186 (package-cross-derivation %store glibc target)))
187 (xbu (derivation->output-path
188 (package-cross-derivation %store binutils target))))
189 (and (lset= equal?
190 `((,%bootstrap-guile "out") (,coreutils "out"))
191 (gexp-native-inputs exp))
192 (lset= equal?
193 `((,glibc "out") (,binutils "out"))
194 (gexp-inputs exp))
195 (equal? `(display (cons '(,guile ,cu) '(,xlibc ,xbu)))
196 (gexp->sexp* exp target)))))
197
21b679f6
LC
198(test-assert "input list splicing"
199 (let* ((inputs (list (list glibc "debug") %bootstrap-guile))
200 (outputs (list (derivation->output-path
201 (package-derivation %store glibc)
202 "debug")
203 (derivation->output-path
204 (package-derivation %store %bootstrap-guile))))
205 (exp (gexp (list (ungexp-splicing (cons (+ 2 3) inputs))))))
206 (and (lset= equal?
207 `((,glibc "debug") (,%bootstrap-guile "out"))
208 (gexp-inputs exp))
209 (equal? (gexp->sexp* exp)
210 `(list ,@(cons 5 outputs))))))
211
667b2508
LC
212(test-assert "input list splicing + ungexp-native-splicing"
213 (let* ((inputs (list (list glibc "debug") %bootstrap-guile))
214 (exp (gexp (list (ungexp-native-splicing (cons (+ 2 3) inputs))))))
215 (and (lset= equal?
216 `((,glibc "debug") (,%bootstrap-guile "out"))
217 (gexp-native-inputs exp))
218 (null? (gexp-inputs exp))
219 (equal? (gexp->sexp* exp) ;native
220 (gexp->sexp* exp "mips64el-linux")))))
221
4b23c466
LC
222(test-equal "output list"
223 2
224 (let ((exp (gexp (begin (mkdir (ungexp output))
225 (mkdir (ungexp output "bar"))))))
226 (length (gexp-outputs exp)))) ;XXX: <output-ref> is private
227
228(test-assert "output list, combined gexps"
229 (let* ((exp0 (gexp (mkdir (ungexp output))))
230 (exp1 (gexp (mkdir (ungexp output "foo"))))
231 (exp2 (gexp (begin (display "hi!") (ungexp exp0) (ungexp exp1)))))
232 (and (lset= equal?
233 (append (gexp-outputs exp0) (gexp-outputs exp1))
234 (gexp-outputs exp2))
235 (= 2 (length (gexp-outputs exp2))))))
236
7e75a673
LC
237(test-equal "output list, combined gexps, duplicate output"
238 1
239 (let* ((exp0 (gexp (mkdir (ungexp output))))
240 (exp1 (gexp (begin (mkdir (ungexp output)) (ungexp exp0))))
241 (exp2 (gexp (begin (mkdir (ungexp output)) (ungexp exp1)))))
242 (length (gexp-outputs exp2))))
243
f9efe568
LC
244(test-assert "output list + ungexp-splicing list, combined gexps"
245 (let* ((exp0 (gexp (mkdir (ungexp output))))
246 (exp1 (gexp (mkdir (ungexp output "foo"))))
247 (exp2 (gexp (begin (display "hi!")
248 (ungexp-splicing (list exp0 exp1))))))
249 (and (lset= equal?
250 (append (gexp-outputs exp0) (gexp-outputs exp1))
251 (gexp-outputs exp2))
252 (= 2 (length (gexp-outputs exp2))))))
253
21b679f6
LC
254(test-assertm "gexp->file"
255 (mlet* %store-monad ((exp -> (gexp (display (ungexp %bootstrap-guile))))
256 (guile (package-file %bootstrap-guile))
257 (sexp (gexp->sexp exp))
258 (drv (gexp->file "foo" exp))
259 (out -> (derivation->output-path drv))
260 (done (built-derivations (list drv)))
261 (refs ((store-lift references) out)))
262 (return (and (equal? sexp (call-with-input-file out read))
263 (equal? (list guile) refs)))))
264
265(test-assertm "gexp->derivation"
266 (mlet* %store-monad ((file (text-file "foo" "Hello, world!"))
267 (exp -> (gexp
268 (begin
269 (mkdir (ungexp output))
270 (chdir (ungexp output))
271 (symlink
272 (string-append (ungexp %bootstrap-guile)
273 "/bin/guile")
274 "foo")
275 (symlink (ungexp file)
276 (ungexp output "2nd")))))
277 (drv (gexp->derivation "foo" exp))
278 (out -> (derivation->output-path drv))
279 (out2 -> (derivation->output-path drv "2nd"))
280 (done (built-derivations (list drv)))
281 (refs ((store-lift references) out))
282 (refs2 ((store-lift references) out2))
283 (guile (package-file %bootstrap-guile "bin/guile")))
284 (return (and (string=? (readlink (string-append out "/foo")) guile)
285 (string=? (readlink out2) file)
286 (equal? refs (list (dirname (dirname guile))))
287 (equal? refs2 (list file))))))
288
ce45eb4c
LC
289(test-assertm "gexp->derivation vs. grafts"
290 (mlet* %store-monad ((p0 -> (dummy-package "dummy"
291 (arguments
292 '(#:implicit-inputs? #f))))
293 (r -> (package (inherit p0) (name "DuMMY")))
294 (p1 -> (package (inherit p0) (replacement r)))
295 (exp0 -> (gexp (frob (ungexp p0) (ungexp output))))
296 (exp1 -> (gexp (frob (ungexp p1) (ungexp output))))
297 (void (set-guile-for-build %bootstrap-guile))
298 (drv0 (gexp->derivation "t" exp0))
299 (drv1 (gexp->derivation "t" exp1))
300 (drv1* (gexp->derivation "t" exp1 #:graft? #f)))
301 (return (and (not (string=? (derivation->output-path drv0)
302 (derivation->output-path drv1)))
303 (string=? (derivation->output-path drv0)
304 (derivation->output-path drv1*))))))
305
21b679f6
LC
306(test-assertm "gexp->derivation, composed gexps"
307 (mlet* %store-monad ((exp0 -> (gexp (begin
308 (mkdir (ungexp output))
309 (chdir (ungexp output)))))
310 (exp1 -> (gexp (symlink
311 (string-append (ungexp %bootstrap-guile)
312 "/bin/guile")
313 "foo")))
314 (exp -> (gexp (begin (ungexp exp0) (ungexp exp1))))
315 (drv (gexp->derivation "foo" exp))
316 (out -> (derivation->output-path drv))
317 (done (built-derivations (list drv)))
318 (guile (package-file %bootstrap-guile "bin/guile")))
319 (return (string=? (readlink (string-append out "/foo"))
320 guile))))
321
5d098459
LC
322(test-assertm "gexp->derivation, default system"
323 ;; The default system should be the one at '>>=' time, not the one at
324 ;; invocation time. See <http://bugs.gnu.org/18002>.
325 (let ((system (%current-system))
326 (mdrv (parameterize ((%current-system "foobar64-linux"))
327 (gexp->derivation "foo"
328 (gexp
329 (mkdir (ungexp output)))))))
330 (mlet %store-monad ((drv mdrv))
331 (return (string=? system (derivation-system drv))))))
332
68a61e9f
LC
333(test-assertm "gexp->derivation, cross-compilation"
334 (mlet* %store-monad ((target -> "mips64el-linux")
335 (exp -> (gexp (list (ungexp coreutils)
336 (ungexp output))))
337 (xdrv (gexp->derivation "foo" exp
338 #:target target))
339 (refs ((store-lift references)
340 (derivation-file-name xdrv)))
341 (xcu (package->cross-derivation coreutils
342 target))
343 (cu (package->derivation coreutils)))
344 (return (and (member (derivation-file-name xcu) refs)
345 (not (member (derivation-file-name cu) refs))))))
346
667b2508
LC
347(test-assertm "gexp->derivation, ungexp-native"
348 (mlet* %store-monad ((target -> "mips64el-linux")
349 (exp -> (gexp (list (ungexp-native coreutils)
350 (ungexp output))))
351 (xdrv (gexp->derivation "foo" exp
352 #:target target))
353 (drv (gexp->derivation "foo" exp)))
354 (return (string=? (derivation-file-name drv)
355 (derivation-file-name xdrv)))))
356
357(test-assertm "gexp->derivation, ungexp + ungexp-native"
358 (mlet* %store-monad ((target -> "mips64el-linux")
359 (exp -> (gexp (list (ungexp-native coreutils)
360 (ungexp glibc)
361 (ungexp output))))
362 (xdrv (gexp->derivation "foo" exp
363 #:target target))
364 (refs ((store-lift references)
365 (derivation-file-name xdrv)))
366 (xglibc (package->cross-derivation glibc target))
367 (cu (package->derivation coreutils)))
368 (return (and (member (derivation-file-name cu) refs)
369 (member (derivation-file-name xglibc) refs)))))
370
371(test-assertm "gexp->derivation, ungexp-native + composed gexps"
372 (mlet* %store-monad ((target -> "mips64el-linux")
373 (exp0 -> (gexp (list 1 2
374 (ungexp coreutils))))
375 (exp -> (gexp (list 0 (ungexp-native exp0))))
376 (xdrv (gexp->derivation "foo" exp
377 #:target target))
378 (drv (gexp->derivation "foo" exp)))
379 (return (string=? (derivation-file-name drv)
380 (derivation-file-name xdrv)))))
381
6fd1a796
LC
382(test-assertm "gexp->derivation, store copy"
383 (let ((build-one #~(call-with-output-file #$output
384 (lambda (port)
385 (display "This is the one." port))))
386 (build-two (lambda (one)
387 #~(begin
388 (mkdir #$output)
389 (symlink #$one (string-append #$output "/one"))
390 (call-with-output-file (string-append #$output "/two")
391 (lambda (port)
392 (display "This is the second one." port))))))
b53833b2
LC
393 (build-drv #~(begin
394 (use-modules (guix build store-copy))
6fd1a796 395
b53833b2
LC
396 (mkdir #$output)
397 (populate-store '("graph") #$output))))
6fd1a796
LC
398 (mlet* %store-monad ((one (gexp->derivation "one" build-one))
399 (two (gexp->derivation "two" (build-two one)))
b53833b2 400 (drv (gexp->derivation "store-copy" build-drv
6fd1a796 401 #:references-graphs
b53833b2 402 `(("graph" ,two))
6fd1a796
LC
403 #:modules
404 '((guix build store-copy)
405 (guix build utils))))
406 (ok? (built-derivations (list drv)))
407 (out -> (derivation->output-path drv)))
408 (let ((one (derivation->output-path one))
409 (two (derivation->output-path two)))
410 (return (and ok?
411 (file-exists? (string-append out "/" one))
412 (file-exists? (string-append out "/" two))
413 (file-exists? (string-append out "/" two "/two"))
414 (string=? (readlink (string-append out "/" two "/one"))
415 one)))))))
416
aa72d9af
LC
417(test-assertm "imported-files"
418 (mlet* %store-monad
419 ((files -> `(("x" . ,(search-path %load-path "ice-9/q.scm"))
420 ("a/b/c" . ,(search-path %load-path
421 "guix/derivations.scm"))
422 ("p/q" . ,(search-path %load-path "guix.scm"))
423 ("p/z" . ,(search-path %load-path "guix/store.scm"))))
424 (drv (imported-files files)))
425 (mbegin %store-monad
426 (built-derivations (list drv))
427 (let ((dir (derivation->output-path drv)))
428 (return
429 (every (match-lambda
430 ((path . source)
431 (equal? (call-with-input-file (string-append dir "/" path)
432 get-bytevector-all)
433 (call-with-input-file source
434 get-bytevector-all))))
435 files))))))
436
437(test-assertm "gexp->derivation #:modules"
438 (mlet* %store-monad
439 ((build -> #~(begin
440 (use-modules (guix build utils))
441 (mkdir-p (string-append #$output "/guile/guix/nix"))
442 #t))
443 (drv (gexp->derivation "test-with-modules" build
444 #:modules '((guix build utils)))))
445 (mbegin %store-monad
446 (built-derivations (list drv))
447 (let* ((p (derivation->output-path drv))
448 (s (stat (string-append p "/guile/guix/nix"))))
449 (return (eq? (stat:type s) 'directory))))))
450
b53833b2
LC
451(test-assertm "gexp->derivation #:references-graphs"
452 (mlet* %store-monad
453 ((one (text-file "one" "hello, world"))
454 (two (gexp->derivation "two"
455 #~(symlink #$one #$output:chbouib)))
456 (drv (gexp->derivation "ref-graphs"
457 #~(begin
458 (use-modules (guix build store-copy))
459 (with-output-to-file #$output
460 (lambda ()
461 (write (call-with-input-file "guile"
462 read-reference-graph))))
463 (with-output-to-file #$output:one
464 (lambda ()
465 (write (call-with-input-file "one"
466 read-reference-graph))))
467 (with-output-to-file #$output:two
468 (lambda ()
469 (write (call-with-input-file "two"
470 read-reference-graph)))))
471 #:references-graphs `(("one" ,one)
472 ("two" ,two "chbouib")
473 ("guile" ,%bootstrap-guile))
474 #:modules '((guix build store-copy)
475 (guix build utils))))
476 (ok? (built-derivations (list drv)))
477 (guile-drv (package->derivation %bootstrap-guile))
478 (g-one -> (derivation->output-path drv "one"))
479 (g-two -> (derivation->output-path drv "two"))
480 (g-guile -> (derivation->output-path drv)))
481 (return (and ok?
482 (equal? (call-with-input-file g-one read) (list one))
483 (equal? (call-with-input-file g-two read)
484 (list one (derivation->output-path two "chbouib")))
485 (equal? (call-with-input-file g-guile read)
486 (list (derivation->output-path guile-drv)))))))
487
c8351d9a
LC
488(test-assertm "gexp->derivation #:allowed-references"
489 (mlet %store-monad ((drv (gexp->derivation "allowed-refs"
490 #~(begin
491 (mkdir #$output)
492 (chdir #$output)
493 (symlink #$output "self")
494 (symlink #$%bootstrap-guile
495 "guile"))
496 #:allowed-references
497 (list "out" %bootstrap-guile))))
498 (built-derivations (list drv))))
499
500(test-assert "gexp->derivation #:allowed-references, disallowed"
501 (let ((drv (run-with-store %store
502 (gexp->derivation "allowed-refs"
503 #~(begin
504 (mkdir #$output)
505 (chdir #$output)
506 (symlink #$%bootstrap-guile "guile"))
507 #:allowed-references '()))))
508 (guard (c ((nix-protocol-error? c) #t))
509 (build-derivations %store (list drv))
510 #f)))
511
c17b5ab4 512(define shebang
c1bc358f 513 (string-append "#!" (derivation->output-path (%guile-for-build))
c17b5ab4
LC
514 "/bin/guile --no-auto-compile"))
515
516;; If we're going to hit the silly shebang limit (128 chars on Linux-based
517;; systems), then skip the following test.
518(test-skip (if (> (string-length shebang) 127) 1 0))
519
21b679f6
LC
520(test-assertm "gexp->script"
521 (mlet* %store-monad ((n -> (random (expt 2 50)))
522 (exp -> (gexp
523 (system*
524 (string-append (ungexp %bootstrap-guile)
525 "/bin/guile")
526 "-c" (object->string
527 '(display (expt (ungexp n) 2))))))
528 (drv (gexp->script "guile-thing" exp
529 #:guile %bootstrap-guile))
530 (out -> (derivation->output-path drv))
531 (done (built-derivations (list drv))))
532 (let* ((pipe (open-input-pipe out))
533 (str (get-string-all pipe)))
534 (return (and (zero? (close-pipe pipe))
535 (= (expt n 2) (string->number str)))))))
536
462a3fa3
LC
537(test-assert "text-file*"
538 (let ((references (store-lift references)))
539 (run-with-store %store
540 (mlet* %store-monad
541 ((drv (package->derivation %bootstrap-guile))
542 (guile -> (derivation->output-path drv))
543 (file (text-file "bar" "This is bar."))
544 (text (text-file* "foo"
545 %bootstrap-guile "/bin/guile "
546 `(,%bootstrap-guile "out") "/bin/guile "
547 drv "/bin/guile "
548 file))
549 (done (built-derivations (list text)))
550 (out -> (derivation->output-path text))
551 (refs (references out)))
552 ;; Make sure we get the right references and the right content.
553 (return (and (lset= string=? refs (list guile file))
554 (equal? (call-with-input-file out get-string-all)
555 (string-append guile "/bin/guile "
556 guile "/bin/guile "
557 guile "/bin/guile "
558 file)))))
559 #:guile-for-build (package-derivation %store %bootstrap-guile))))
560
2cf0ea0d
LC
561(test-assert "printer"
562 (string-match "^#<gexp \\(string-append .*#<package coreutils.*\
563 \"/bin/uname\"\\) [[:xdigit:]]+>$"
564 (with-output-to-string
565 (lambda ()
566 (write
567 (gexp (string-append (ungexp coreutils)
568 "/bin/uname")))))))
569
570(test-assert "printer vs. ungexp-splicing"
571 (string-match "^#<gexp .* [[:xdigit:]]+>$"
572 (with-output-to-string
573 (lambda ()
574 ;; #~(begin #$@#~())
575 (write
576 (gexp (begin (ungexp-splicing (gexp ())))))))))
577
21b679f6
LC
578(test-equal "sugar"
579 '(gexp (foo (ungexp bar) (ungexp baz "out")
580 (ungexp (chbouib 42))
667b2508
LC
581 (ungexp-splicing (list x y z))
582 (ungexp-native foo) (ungexp-native foo "out")
583 (ungexp-native (chbouib 42))
584 (ungexp-native-splicing (list x y z))))
585 '#~(foo #$bar #$baz:out #$(chbouib 42) #$@(list x y z)
586 #+foo #+foo:out #+(chbouib 42) #+@(list x y z)))
21b679f6
LC
587
588(test-end "gexp")
589
590\f
591(exit (= (test-runner-fail-count (test-runner-current)) 0))
592
593;; Local Variables:
594;; eval: (put 'test-assertm 'scheme-indent-function 1)
595;; End: