1 ;;;; tree-il.test --- test suite for compiling tree-il -*- scheme -*-
2 ;;;; Andy Wingo <wingo@pobox.com> --- May 2009
4 ;;;; Copyright (C) 2009 Free Software Foundation, Inc.
6 ;;;; This library is free software; you can redistribute it and/or
7 ;;;; modify it under the terms of the GNU Lesser General Public
8 ;;;; License as published by the Free Software Foundation; either
9 ;;;; version 3 of the License, or (at your option) any later version.
11 ;;;; This library is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;;; Lesser General Public License for more details.
16 ;;;; You should have received a copy of the GNU Lesser General Public
17 ;;;; License along with this library; if not, write to the Free Software
18 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 (define-module (test-suite tree-il)
21 #:use-module (test-suite lib)
22 #:use-module (system base compile)
23 #:use-module (system base pmatch)
24 #:use-module (system base message)
25 #:use-module (language tree-il)
26 #:use-module (language glil)
27 #:use-module (srfi srfi-13))
29 ;; Of course, the GLIL that is emitted depends on the source info of the
30 ;; input. Here we're not concerned about that, so we strip source
31 ;; information from the incoming tree-il.
33 (define (strip-source x)
34 (post-order! (lambda (x) (set! (tree-il-src x) #f))
37 (define-syntax assert-scheme->glil
40 (let ((tree-il (strip-source
41 (compile 'in #:from 'scheme #:to 'tree-il))))
43 (equal? (unparse-glil (compile tree-il #:from 'tree-il #:to 'glil))
46 (define-syntax assert-tree-il->glil
51 (let ((glil (unparse-glil
52 (compile (strip-source (parse-tree-il exp))
53 #:from 'tree-il #:to 'glil))))
55 (pat (guard test ...) #t)
58 (with-test-prefix "void"
61 (program () (std-prelude 0 0 #f) (label _) (void) (call return 1)))
63 (begin (void) (const 1))
64 (program () (std-prelude 0 0 #f) (label _) (const 1) (call return 1)))
66 (apply (primitive +) (void) (const 1))
67 (program () (std-prelude 0 0 #f) (label _) (void) (call add1 1) (call return 1))))
69 (with-test-prefix "application"
71 (apply (toplevel foo) (const 1))
72 (program () (std-prelude 0 0 #f) (label _) (toplevel ref foo) (const 1) (call goto/args 1)))
74 (begin (apply (toplevel foo) (const 1)) (void))
75 (program () (std-prelude 0 0 #f) (label _) (call new-frame 0) (toplevel ref foo) (const 1) (mv-call 1 ,l1)
76 (call drop 1) (branch br ,l2)
77 (label ,l3) (mv-bind () #f) (unbind)
79 (void) (call return 1))
80 (and (eq? l1 l3) (eq? l2 l4)))
82 (apply (toplevel foo) (apply (toplevel bar)))
83 (program () (std-prelude 0 0 #f) (label _) (toplevel ref foo) (call new-frame 0) (toplevel ref bar) (call call 0)
86 (with-test-prefix "conditional"
88 (if (const #t) (const 1) (const 2))
89 (program () (std-prelude 0 0 #f) (label _) (const #t) (branch br-if-not ,l1)
90 (const 1) (call return 1)
91 (label ,l2) (const 2) (call return 1))
95 (begin (if (const #t) (const 1) (const 2)) (const #f))
96 (program () (std-prelude 0 0 #f) (label _) (const #t) (branch br-if-not ,l1) (branch br ,l2)
97 (label ,l3) (label ,l4) (const #f) (call return 1))
98 (eq? l1 l3) (eq? l2 l4))
100 (assert-tree-il->glil
101 (apply (primitive null?) (if (const #t) (const 1) (const 2)))
102 (program () (std-prelude 0 0 #f) (label _) (const #t) (branch br-if-not ,l1)
103 (const 1) (branch br ,l2)
104 (label ,l3) (const 2) (label ,l4)
105 (call null? 1) (call return 1))
106 (eq? l1 l3) (eq? l2 l4)))
108 (with-test-prefix "primitive-ref"
109 (assert-tree-il->glil
111 (program () (std-prelude 0 0 #f) (label _) (toplevel ref +) (call return 1)))
113 (assert-tree-il->glil
114 (begin (primitive +) (const #f))
115 (program () (std-prelude 0 0 #f) (label _) (const #f) (call return 1)))
117 (assert-tree-il->glil
118 (apply (primitive null?) (primitive +))
119 (program () (std-prelude 0 0 #f) (label _) (toplevel ref +) (call null? 1)
122 (with-test-prefix "lexical refs"
123 (assert-tree-il->glil
124 (let (x) (y) ((const 1)) (lexical x y))
125 (program () (std-prelude 0 1 #f) (label _)
126 (const 1) (bind (x #f 0)) (lexical #t #f set 0)
127 (lexical #t #f ref 0) (call return 1)
130 (assert-tree-il->glil
131 (let (x) (y) ((const 1)) (begin (lexical x y) (const #f)))
132 (program () (std-prelude 0 1 #f) (label _)
133 (const 1) (bind (x #f 0)) (lexical #t #f set 0)
134 (const #f) (call return 1)
137 (assert-tree-il->glil
138 (let (x) (y) ((const 1)) (apply (primitive null?) (lexical x y)))
139 (program () (std-prelude 0 1 #f) (label _)
140 (const 1) (bind (x #f 0)) (lexical #t #f set 0)
141 (lexical #t #f ref 0) (call null? 1) (call return 1)
144 (with-test-prefix "lexical sets"
145 (assert-tree-il->glil
146 ;; unreferenced sets may be optimized away -- make sure they are ref'd
147 (let (x) (y) ((const 1))
148 (set! (lexical x y) (apply (primitive 1+) (lexical x y))))
149 (program () (std-prelude 0 1 #f) (label _)
150 (const 1) (bind (x #t 0)) (lexical #t #t box 0)
151 (lexical #t #t ref 0) (call add1 1) (lexical #t #t set 0)
152 (void) (call return 1)
155 (assert-tree-il->glil
156 (let (x) (y) ((const 1))
157 (begin (set! (lexical x y) (apply (primitive 1+) (lexical x y)))
159 (program () (std-prelude 0 1 #f) (label _)
160 (const 1) (bind (x #t 0)) (lexical #t #t box 0)
161 (lexical #t #t ref 0) (call add1 1) (lexical #t #t set 0)
162 (lexical #t #t ref 0) (call return 1)
165 (assert-tree-il->glil
166 (let (x) (y) ((const 1))
167 (apply (primitive null?)
168 (set! (lexical x y) (apply (primitive 1+) (lexical x y)))))
169 (program () (std-prelude 0 1 #f) (label _)
170 (const 1) (bind (x #t 0)) (lexical #t #t box 0)
171 (lexical #t #t ref 0) (call add1 1) (lexical #t #t set 0) (void)
172 (call null? 1) (call return 1)
175 (with-test-prefix "module refs"
176 (assert-tree-il->glil
178 (program () (std-prelude 0 0 #f) (label _)
179 (module public ref (foo) bar)
182 (assert-tree-il->glil
183 (begin (@ (foo) bar) (const #f))
184 (program () (std-prelude 0 0 #f) (label _)
185 (module public ref (foo) bar) (call drop 1)
186 (const #f) (call return 1)))
188 (assert-tree-il->glil
189 (apply (primitive null?) (@ (foo) bar))
190 (program () (std-prelude 0 0 #f) (label _)
191 (module public ref (foo) bar)
192 (call null? 1) (call return 1)))
194 (assert-tree-il->glil
196 (program () (std-prelude 0 0 #f) (label _)
197 (module private ref (foo) bar)
200 (assert-tree-il->glil
201 (begin (@@ (foo) bar) (const #f))
202 (program () (std-prelude 0 0 #f) (label _)
203 (module private ref (foo) bar) (call drop 1)
204 (const #f) (call return 1)))
206 (assert-tree-il->glil
207 (apply (primitive null?) (@@ (foo) bar))
208 (program () (std-prelude 0 0 #f) (label _)
209 (module private ref (foo) bar)
210 (call null? 1) (call return 1))))
212 (with-test-prefix "module sets"
213 (assert-tree-il->glil
214 (set! (@ (foo) bar) (const 2))
215 (program () (std-prelude 0 0 #f) (label _)
216 (const 2) (module public set (foo) bar)
217 (void) (call return 1)))
219 (assert-tree-il->glil
220 (begin (set! (@ (foo) bar) (const 2)) (const #f))
221 (program () (std-prelude 0 0 #f) (label _)
222 (const 2) (module public set (foo) bar)
223 (const #f) (call return 1)))
225 (assert-tree-il->glil
226 (apply (primitive null?) (set! (@ (foo) bar) (const 2)))
227 (program () (std-prelude 0 0 #f) (label _)
228 (const 2) (module public set (foo) bar)
229 (void) (call null? 1) (call return 1)))
231 (assert-tree-il->glil
232 (set! (@@ (foo) bar) (const 2))
233 (program () (std-prelude 0 0 #f) (label _)
234 (const 2) (module private set (foo) bar)
235 (void) (call return 1)))
237 (assert-tree-il->glil
238 (begin (set! (@@ (foo) bar) (const 2)) (const #f))
239 (program () (std-prelude 0 0 #f) (label _)
240 (const 2) (module private set (foo) bar)
241 (const #f) (call return 1)))
243 (assert-tree-il->glil
244 (apply (primitive null?) (set! (@@ (foo) bar) (const 2)))
245 (program () (std-prelude 0 0 #f) (label _)
246 (const 2) (module private set (foo) bar)
247 (void) (call null? 1) (call return 1))))
249 (with-test-prefix "toplevel refs"
250 (assert-tree-il->glil
252 (program () (std-prelude 0 0 #f) (label _)
256 (assert-tree-il->glil
257 (begin (toplevel bar) (const #f))
258 (program () (std-prelude 0 0 #f) (label _)
259 (toplevel ref bar) (call drop 1)
260 (const #f) (call return 1)))
262 (assert-tree-il->glil
263 (apply (primitive null?) (toplevel bar))
264 (program () (std-prelude 0 0 #f) (label _)
266 (call null? 1) (call return 1))))
268 (with-test-prefix "toplevel sets"
269 (assert-tree-il->glil
270 (set! (toplevel bar) (const 2))
271 (program () (std-prelude 0 0 #f) (label _)
272 (const 2) (toplevel set bar)
273 (void) (call return 1)))
275 (assert-tree-il->glil
276 (begin (set! (toplevel bar) (const 2)) (const #f))
277 (program () (std-prelude 0 0 #f) (label _)
278 (const 2) (toplevel set bar)
279 (const #f) (call return 1)))
281 (assert-tree-il->glil
282 (apply (primitive null?) (set! (toplevel bar) (const 2)))
283 (program () (std-prelude 0 0 #f) (label _)
284 (const 2) (toplevel set bar)
285 (void) (call null? 1) (call return 1))))
287 (with-test-prefix "toplevel defines"
288 (assert-tree-il->glil
289 (define bar (const 2))
290 (program () (std-prelude 0 0 #f) (label _)
291 (const 2) (toplevel define bar)
292 (void) (call return 1)))
294 (assert-tree-il->glil
295 (begin (define bar (const 2)) (const #f))
296 (program () (std-prelude 0 0 #f) (label _)
297 (const 2) (toplevel define bar)
298 (const #f) (call return 1)))
300 (assert-tree-il->glil
301 (apply (primitive null?) (define bar (const 2)))
302 (program () (std-prelude 0 0 #f) (label _)
303 (const 2) (toplevel define bar)
304 (void) (call null? 1) (call return 1))))
306 (with-test-prefix "constants"
307 (assert-tree-il->glil
309 (program () (std-prelude 0 0 #f) (label _)
310 (const 2) (call return 1)))
312 (assert-tree-il->glil
313 (begin (const 2) (const #f))
314 (program () (std-prelude 0 0 #f) (label _)
315 (const #f) (call return 1)))
317 (assert-tree-il->glil
318 (apply (primitive null?) (const 2))
319 (program () (std-prelude 0 0 #f) (label _)
320 (const 2) (call null? 1) (call return 1))))
322 (with-test-prefix "lambda"
323 (assert-tree-il->glil
325 (lambda-case (((x) #f #f #f () (y) #f) (const 2)) #f))
326 (program () (std-prelude 0 0 #f) (label _)
327 (program () (std-prelude 1 1 #f)
328 (bind (x #f 0)) (label _)
329 (const 2) (call return 1) (unbind))
332 (assert-tree-il->glil
334 (lambda-case (((x y) #f #f #f () (x1 y1) #f)
337 (program () (std-prelude 0 0 #f) (label _)
338 (program () (std-prelude 2 2 #f)
339 (bind (x #f 0) (y #f 1)) (label _)
340 (const 2) (call return 1)
344 (assert-tree-il->glil
346 (lambda-case ((() #f x #f () (y) #f) (const 2))
348 (program () (std-prelude 0 0 #f) (label _)
349 (program () (opt-prelude 0 0 0 1 #f)
350 (bind (x #f 0)) (label _)
351 (const 2) (call return 1)
355 (assert-tree-il->glil
357 (lambda-case (((x) #f x1 #f () (y y1) #f) (const 2))
359 (program () (std-prelude 0 0 #f) (label _)
360 (program () (opt-prelude 1 0 1 2 #f)
361 (bind (x #f 0) (x1 #f 1)) (label _)
362 (const 2) (call return 1)
366 (assert-tree-il->glil
368 (lambda-case (((x) #f x1 #f () (y y1) #f) (lexical x y))
370 (program () (std-prelude 0 0 #f) (label _)
371 (program () (opt-prelude 1 0 1 2 #f)
372 (bind (x #f 0) (x1 #f 1)) (label _)
373 (lexical #t #f ref 0) (call return 1)
377 (assert-tree-il->glil
379 (lambda-case (((x) #f x1 #f () (y y1) #f) (lexical x1 y1))
381 (program () (std-prelude 0 0 #f) (label _)
382 (program () (opt-prelude 1 0 1 2 #f)
383 (bind (x #f 0) (x1 #f 1)) (label _)
384 (lexical #t #f ref 1) (call return 1)
388 (assert-tree-il->glil
390 (lambda-case (((x) #f #f #f () (x1) #f)
392 (lambda-case (((y) #f #f #f () (y1) #f)
396 (program () (std-prelude 0 0 #f) (label _)
397 (program () (std-prelude 1 1 #f)
398 (bind (x #f 0)) (label _)
399 (program () (std-prelude 1 1 #f)
400 (bind (y #f 0)) (label _)
401 (lexical #f #f ref 0) (call return 1)
403 (lexical #t #f ref 0)
405 (call make-closure 2)
410 (with-test-prefix "sequence"
411 (assert-tree-il->glil
412 (begin (begin (const 2) (const #f)) (const #t))
413 (program () (std-prelude 0 0 #f) (label _)
414 (const #t) (call return 1)))
416 (assert-tree-il->glil
417 (apply (primitive null?) (begin (const #f) (const 2)))
418 (program () (std-prelude 0 0 #f) (label _)
419 (const 2) (call null? 1) (call return 1))))
421 ;; FIXME: binding info for or-hacked locals might bork the disassembler,
422 ;; and could be tightened in any case
423 (with-test-prefix "the or hack"
424 (assert-tree-il->glil
425 (let (x) (y) ((const 1))
428 (let (a) (b) ((const 2))
430 (program () (std-prelude 0 1 #f) (label _)
431 (const 1) (bind (x #f 0)) (lexical #t #f set 0)
432 (lexical #t #f ref 0) (branch br-if-not ,l1)
433 (lexical #t #f ref 0) (call return 1)
435 (const 2) (bind (a #f 0)) (lexical #t #f set 0)
436 (lexical #t #f ref 0) (call return 1)
441 ;; second bound var is unreferenced
442 (assert-tree-il->glil
443 (let (x) (y) ((const 1))
446 (let (a) (b) ((const 2))
448 (program () (std-prelude 0 1 #f) (label _)
449 (const 1) (bind (x #f 0)) (lexical #t #f set 0)
450 (lexical #t #f ref 0) (branch br-if-not ,l1)
451 (lexical #t #f ref 0) (call return 1)
453 (lexical #t #f ref 0) (call return 1)
457 (with-test-prefix "apply"
458 (assert-tree-il->glil
459 (apply (primitive @apply) (toplevel foo) (toplevel bar))
460 (program () (std-prelude 0 0 #f) (label _) (toplevel ref foo) (toplevel ref bar) (call goto/apply 2)))
461 (assert-tree-il->glil
462 (begin (apply (primitive @apply) (toplevel foo) (toplevel bar)) (void))
463 (program () (std-prelude 0 0 #f) (label _)
464 (call new-frame 0) (toplevel ref apply) (toplevel ref foo) (toplevel ref bar) (mv-call 2 ,l1)
465 (call drop 1) (branch br ,l2) (label ,l3) (mv-bind () #f) (unbind)
467 (void) (call return 1))
468 (and (eq? l1 l3) (eq? l2 l4)))
469 (assert-tree-il->glil
470 (apply (toplevel foo) (apply (toplevel @apply) (toplevel bar) (toplevel baz)))
471 (program () (std-prelude 0 0 #f) (label _)
473 (call new-frame 0) (toplevel ref bar) (toplevel ref baz) (call apply 2)
474 (call goto/args 1))))
476 (with-test-prefix "call/cc"
477 (assert-tree-il->glil
478 (apply (primitive @call-with-current-continuation) (toplevel foo))
479 (program () (std-prelude 0 0 #f) (label _) (toplevel ref foo) (call goto/cc 1)))
480 (assert-tree-il->glil
481 (begin (apply (primitive @call-with-current-continuation) (toplevel foo)) (void))
482 (program () (std-prelude 0 0 #f) (label _)
483 (call new-frame 0) (toplevel ref call-with-current-continuation) (toplevel ref foo) (mv-call 1 ,l1)
484 (call drop 1) (branch br ,l2) (label ,l3) (mv-bind () #f) (unbind)
486 (void) (call return 1))
487 (and (eq? l1 l3) (eq? l2 l4)))
488 (assert-tree-il->glil
489 (apply (toplevel foo)
490 (apply (toplevel @call-with-current-continuation) (toplevel bar)))
491 (program () (std-prelude 0 0 #f) (label _)
493 (toplevel ref bar) (call call/cc 1)
494 (call goto/args 1))))
497 (with-test-prefix "tree-il-fold"
499 (pass-if "empty tree"
500 (let ((leaf? #f) (up? #f) (down? #f) (mark (list 'mark)))
502 (tree-il-fold (lambda (x y) (set! leaf? #t) y)
503 (lambda (x y) (set! down? #t) y)
504 (lambda (x y) (set! up? #t) y)
511 (pass-if "lambda and application"
512 (let* ((leaves '()) (ups '()) (downs '())
513 (result (tree-il-fold (lambda (x y)
514 (set! leaves (cons x leaves))
517 (set! downs (cons x downs))
520 (set! ups (cons x ups))
526 (((x y) #f #f #f () (x1 y1) #f)
531 (and (equal? (map strip-source leaves)
532 (list (make-lexical-ref #f 'y 'y1)
533 (make-lexical-ref #f 'x 'x1)
534 (make-toplevel-ref #f '+)))
536 (equal? (reverse (map strip-source ups))
537 (map strip-source downs))))))
544 ;; Make sure we get English messages.
545 (setlocale LC_ALL "C")
547 (define (call-with-warnings thunk)
548 (let ((port (open-output-string)))
549 (with-fluid* *current-warning-port* port
551 (let ((warnings (get-output-string port)))
552 (string-tokenize warnings
553 (char-set-complement (char-set #\newline))))))
555 (define %opts-w-unused
556 '(#:warnings (unused-variable)))
558 (define %opts-w-unbound
559 '(#:warnings (unbound-variable)))
561 (define %opts-w-arity
562 '(#:warnings (arity-mismatch)))
565 (with-test-prefix "warnings"
567 (pass-if "unknown warning type"
568 (let ((w (call-with-warnings
570 (compile #t #:opts '(#:warnings (does-not-exist)))))))
571 (and (= (length w) 1)
572 (number? (string-contains (car w) "unknown warning")))))
574 (with-test-prefix "unused-variable"
577 (null? (call-with-warnings
579 (compile '(lambda (x y) (+ x y))
580 #:opts %opts-w-unused)))))
582 (pass-if "let/unused"
583 (let ((w (call-with-warnings
585 (compile '(lambda (x)
588 #:opts %opts-w-unused)))))
589 (and (= (length w) 1)
590 (number? (string-contains (car w) "unused variable `y'")))))
592 (pass-if "shadowed variable"
593 (let ((w (call-with-warnings
595 (compile '(lambda (x)
599 #:opts %opts-w-unused)))))
600 (and (= (length w) 1)
601 (number? (string-contains (car w) "unused variable `y'")))))
604 (null? (call-with-warnings
607 (letrec ((x (lambda () (y)))
610 #:opts %opts-w-unused)))))
612 (pass-if "unused argument"
613 ;; Unused arguments should not be reported.
614 (null? (call-with-warnings
616 (compile '(lambda (x y z) #t)
617 #:opts %opts-w-unused))))))
619 (with-test-prefix "unbound variable"
622 (null? (call-with-warnings
624 (compile '+ #:opts %opts-w-unbound)))))
628 (w (call-with-warnings
632 #:opts %opts-w-unbound)))))
633 (and (= (length w) 1)
634 (number? (string-contains (car w)
635 (format #f "unbound variable `~A'"
640 (w (call-with-warnings
642 (compile `(set! ,v 7)
644 #:opts %opts-w-unbound)))))
645 (and (= (length w) 1)
646 (number? (string-contains (car w)
647 (format #f "unbound variable `~A'"
650 (pass-if "module-local top-level is visible"
651 (let ((m (make-module))
653 (beautify-user-module! m)
654 (compile `(define ,v 123)
655 #:env m #:opts %opts-w-unbound)
656 (null? (call-with-warnings
661 #:opts %opts-w-unbound))))))
663 (pass-if "module-local top-level is visible after"
664 (let ((m (make-module))
666 (beautify-user-module! m)
667 (null? (call-with-warnings
669 (let ((in (open-input-string
672 (define chbouib 5)")))
675 #:opts %opts-w-unbound)))))))
677 (pass-if "optional arguments are visible"
678 (null? (call-with-warnings
680 (compile '(lambda* (x #:optional y z) (list x y z))
681 #:opts %opts-w-unbound
684 (pass-if "keyword arguments are visible"
685 (null? (call-with-warnings
687 (compile '(lambda* (x #:key y z) (list x y z))
688 #:opts %opts-w-unbound
691 (pass-if "GOOPS definitions are visible"
692 (let ((m (make-module))
694 (beautify-user-module! m)
695 (module-use! m (resolve-interface '(oop goops)))
696 (null? (call-with-warnings
698 (let ((in (open-input-string
699 "(define-class <foo> ()
700 (bar #:getter foo-bar))
701 (define z (foo-bar (make <foo>)))")))
704 #:opts %opts-w-unbound))))))))
706 (with-test-prefix "arity mismatch"
709 (null? (call-with-warnings
711 (compile '(cons 'a 'b) #:opts %opts-w-arity)))))
713 (pass-if "direct application"
714 (let ((w (call-with-warnings
716 (compile '((lambda (x y) (or x y)) 1 2 3 4 5)
719 (and (= (length w) 1)
720 (number? (string-contains (car w)
721 "wrong number of arguments to")))))
723 (let ((w (call-with-warnings
725 (compile '(let ((f (lambda (x y) (+ x y))))
729 (and (= (length w) 1)
730 (number? (string-contains (car w)
731 "wrong number of arguments to")))))
734 (let ((w (call-with-warnings
736 (compile '(cons 1 2 3 4)
739 (and (= (length w) 1)
740 (number? (string-contains (car w)
741 "wrong number of arguments to")))))
743 (pass-if "alias to global"
744 (let ((w (call-with-warnings
746 (compile '(let ((f cons)) (f 1 2 3 4))
749 (and (= (length w) 1)
750 (number? (string-contains (car w)
751 "wrong number of arguments to")))))
753 (pass-if "alias to lexical to global"
754 (let ((w (call-with-warnings
756 (compile '(let ((f number?))
761 (and (= (length w) 1)
762 (number? (string-contains (car w)
763 "wrong number of arguments to")))))
765 (pass-if "alias to lexical"
766 (let ((w (call-with-warnings
768 (compile '(let ((f (lambda (x y z) (+ x y z))))
773 (and (= (length w) 1)
774 (number? (string-contains (car w)
775 "wrong number of arguments to")))))
778 (let ((w (call-with-warnings
780 (compile '(letrec ((odd? (lambda (x) (even? (1- x))))
787 (and (= (length w) 1)
788 (number? (string-contains (car w)
789 "wrong number of arguments to")))))
791 (pass-if "local toplevel-defines"
792 (let ((w (call-with-warnings
794 (let ((in (open-input-string "
800 (and (= (length w) 1)
801 (number? (string-contains (car w)
802 "wrong number of arguments to")))))
804 (pass-if "global toplevel alias"
805 (let ((w (call-with-warnings
807 (let ((in (open-input-string "
813 (and (= (length w) 1)
814 (number? (string-contains (car w)
815 "wrong number of arguments to")))))
817 (pass-if "local toplevel overrides global"
818 (null? (call-with-warnings
820 (let ((in (open-input-string "
822 (define (foo x) (cons))")))
827 (pass-if "keyword not passed and quiet"
828 (null? (call-with-warnings
830 (compile '(let ((f (lambda* (x #:key y) y)))
835 (pass-if "keyword passed and quiet"
836 (null? (call-with-warnings
838 (compile '(let ((f (lambda* (x #:key y) y)))
843 (pass-if "keyword passed to global and quiet"
844 (null? (call-with-warnings
846 (let ((in (open-input-string "
847 (use-modules (system base compile))
848 (compile '(+ 2 3) #:env (current-module))")))
853 (pass-if "extra keyword"
854 (let ((w (call-with-warnings
856 (compile '(let ((f (lambda* (x #:key y) y)))
860 (and (= (length w) 1)
861 (number? (string-contains (car w)
862 "wrong number of arguments to")))))
864 (pass-if "extra keywords allowed"
865 (null? (call-with-warnings
867 (compile '(let ((f (lambda* (x #:key y #:allow-other-keys)
871 #:to 'assembly)))))))