~ubuntu-branches/ubuntu/hardy/sigscheme/hardy-proposed

« back to all changes in this revision

Viewing changes to test/test-define.scm

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2006-05-23 21:46:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060523214641-6ix4gz34wpiehub8
Tags: 0.5.0-2
* debian/control (Build-Depends): Added ruby.
  Thanks to Frederik Schueler.  Closes: #368571
* debian/rules (clean): invoke 'distclean' instead of 'clean'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;  FileName : test-define.scm
 
2
;;  About    : unit test for R5RS 'define'
 
3
;;
 
4
;;  Copyright (C) 2005-2006 Kazuki Ohta <mover AT hct.zaq.ne.jp>
 
5
;;
 
6
;;  All rights reserved.
 
7
;;
 
8
;;  Redistribution and use in source and binary forms, with or without
 
9
;;  modification, are permitted provided that the following conditions
 
10
;;  are met:
 
11
;;
 
12
;;  1. Redistributions of source code must retain the above copyright
 
13
;;     notice, this list of conditions and the following disclaimer.
 
14
;;  2. Redistributions in binary form must reproduce the above copyright
 
15
;;     notice, this list of conditions and the following disclaimer in the
 
16
;;     documentation and/or other materials provided with the distribution.
 
17
;;  3. Neither the name of authors nor the names of its contributors
 
18
;;     may be used to endorse or promote products derived from this software
 
19
;;     without specific prior written permission.
 
20
;;
 
21
;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 
22
;;  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
23
;;  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
24
;;  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
 
25
;;  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
26
;;  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
27
;;  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
28
;;  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
29
;;  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
30
;;  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
31
;;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
 
 
33
(load "./test/unittest.scm")
 
34
 
 
35
(define tn test-name)
 
36
(define *test-track-progress* #f)
 
37
 
 
38
; invalid form
 
39
(assert-error "define invalid form #1"
 
40
              (lambda ()
 
41
                (define)))
 
42
(assert-error "define invalid form #2"
 
43
              (lambda ()
 
44
                (define a)))
 
45
(assert-error "define invalid form #3"
 
46
              (lambda ()
 
47
                (define 1 1)))
 
48
(assert-error "define invalid form #4"
 
49
              (lambda ()
 
50
                (define a 1 'excessive)))
 
51
(assert-error "define invalid form #5"
 
52
              (lambda ()
 
53
                (define a . 2)))
 
54
(if (and (provided? "sigscheme")
 
55
         (provided? "strict-argcheck"))
 
56
    (assert-error "define invalid form #6"
 
57
                  (lambda ()
 
58
                    (define (f x) . x))))
 
59
 
 
60
; basic define
 
61
(define val1 3)
 
62
(assert-equal? "basic define check" 3 val1)
 
63
 
 
64
; redefine
 
65
(define val1 5)
 
66
(assert-equal? "redefine check" 5 val1)
 
67
 
 
68
; define lambda
 
69
(define (what? x)
 
70
  "DEADBEEF" x)
 
71
(assert-equal? "func define" 10 (what? 10))
 
72
 
 
73
(define what2?
 
74
  (lambda (x)
 
75
    "DEADBEEF" x))
 
76
(assert-equal? "func define" 10 (what2? 10))
 
77
 
 
78
(define (nullarg)
 
79
  "nullarg")
 
80
(assert-equal? "nullarg test" "nullarg" (nullarg))
 
81
 
 
82
(define (add x y)
 
83
  (+ x y))
 
84
(assert-equal? "func define" 10 (add 2 8))
 
85
 
 
86
; tests for dot list arguments
 
87
(define (dotarg1 . a)
 
88
  a)
 
89
(assert-equal? "dot arg test 1" '(1 2) (dotarg1 1 2))
 
90
 
 
91
(define (dotarg2 a . b)
 
92
  a)
 
93
(assert-equal? "dot arg test 2" 1 (dotarg2 1 2))
 
94
 
 
95
(define (dotarg3 a . b)
 
96
  b)
 
97
(assert-equal? "dot arg test 3" '(2) (dotarg3 1 2))
 
98
(assert-equal? "dot arg test 4" '(2 3) (dotarg3 1 2 3))
 
99
 
 
100
 
 
101
(define (dotarg4 a b . c)
 
102
  b)
 
103
(assert-equal? "dot arg test 5" 2 (dotarg4 1 2 3))
 
104
 
 
105
(define (dotarg5 a b . c)
 
106
  c)
 
107
(assert-equal? "dot arg test 6" '(3 4) (dotarg5 1 2 3 4))
 
108
 
 
109
; test for internal define
 
110
(define (idefine-o a)
 
111
  (define (idefine-i c)
 
112
    (+ c 3))
 
113
  (idefine-i a))
 
114
 
 
115
(assert-equal? "internal define1" 5 (idefine-o 2))
 
116
 
 
117
(define (idefine0 a)
 
118
  (define (idefine1 . args)
 
119
    (apply +  args))
 
120
  (define (idefine2 c)
 
121
    (+ c 2))
 
122
  (+ (idefine1 1 2 3 4 5) (idefine2 a)))
 
123
 
 
124
(assert-equal? "internal define2" 17 (idefine0 0))
 
125
 
 
126
(if (or (symbol-bound? 'f)
 
127
        (symbol-bound? 'x)
 
128
        (symbol-bound? 'y)
 
129
        (symbol-bound? 'foo)
 
130
        (symbol-bound? 'bar))
 
131
    (error "global variables for internal definitions tests are tainted"))
 
132
 
 
133
(tn "internal defintions")
 
134
(assert-equal? (tn)
 
135
               14
 
136
               (let ((x 5))
 
137
                 (+ (let ()
 
138
                      (define x 6)
 
139
                      (+ x 3))
 
140
                    x)))
 
141
(assert-equal? (tn)
 
142
               14
 
143
               (let ((x 5))
 
144
                 (+ (let* ()
 
145
                      (define x 6)
 
146
                      (+ x 3))
 
147
                    x)))
 
148
(assert-equal? (tn)
 
149
               14
 
150
               (let ((x 5))
 
151
                 (+ (letrec ()
 
152
                      (define x 6)
 
153
                      (+ x 3))
 
154
                    x)))
 
155
(assert-equal? (tn)
 
156
               14
 
157
               (let ((x 5))
 
158
                 (+ ((lambda ()
 
159
                       (define x 6)
 
160
                       (+ x 3)))
 
161
                    x)))
 
162
(assert-equal? (tn)
 
163
               14
 
164
               (let ((x 5))
 
165
                 (+ (let ()
 
166
                      (define (f)
 
167
                        (define x 6)
 
168
                        (+ x 3))
 
169
                      (f))
 
170
                    x)))
 
171
 
 
172
(tn "internal defintions: letrec-like behavior")
 
173
(assert-equal? (tn)
 
174
               45
 
175
               (let ((x 5))
 
176
                 (define foo (lambda (y) (bar x y)))
 
177
                 (define bar (lambda (a b) (+ (* a b) a)))
 
178
                 (foo (+ x 3))))
 
179
(assert-equal? (tn)
 
180
               45
 
181
               (let ((x 5))
 
182
                 (define bar (lambda (a b) (+ (* a b) a)))
 
183
                 (define foo (lambda (y) (bar x y)))
 
184
                 (foo (+ x 3))))
 
185
(assert-error (tn)
 
186
               (lambda ()
 
187
                 (let ((x 5))
 
188
                   (define foo bar)
 
189
                   (define bar (lambda (a b) (+ (* a b) a)))
 
190
                   (foo x (+ x 3)))))
 
191
(assert-error  (tn)
 
192
               (lambda ()
 
193
                 (let ((x 5))
 
194
                   (define bar (lambda (a b) (+ (* a b) a)))
 
195
                   (define foo bar)
 
196
                   (foo x (+ x 3)))))
 
197
(assert-error  (tn)
 
198
               (lambda ()
 
199
                 (let ()
 
200
                   (define foo 1)
 
201
                   (define bar (+ foo 1))
 
202
                   (+ foo bar))))
 
203
(assert-error  (tn)
 
204
               (lambda ()
 
205
                 (let ()
 
206
                   (define bar (+ foo 1))
 
207
                   (define foo 1)
 
208
                   (+ foo bar))))
 
209
(assert-error  (tn)
 
210
               (lambda ()
 
211
                 (let ((foo 3))
 
212
                   (define foo 1)
 
213
                   (define bar (+ foo 1))
 
214
                   (+ foo bar))))
 
215
(assert-error  (tn)
 
216
               (lambda ()
 
217
                 (let ((foo 3))
 
218
                   (define bar (+ foo 1))
 
219
                   (define foo 1)
 
220
                   (+ foo bar))))
 
221
 
 
222
(tn "internal defintions: non-beginning of block")
 
223
(assert-error  (tn)
 
224
               (lambda ()
 
225
                 (let ()
 
226
                   (define foo 1)
 
227
                   (set! foo 5)
 
228
                   (define bar 2)
 
229
                   (+ foo bar))))
 
230
(assert-error  (tn)
 
231
               (lambda ()
 
232
                 (let* ()
 
233
                   (define foo 1)
 
234
                   (set! foo 5)
 
235
                   (define bar 2)
 
236
                   (+ foo bar))))
 
237
(assert-error  (tn)
 
238
               (lambda ()
 
239
                 (letrec ()
 
240
                   (define foo 1)
 
241
                   (set! foo 5)
 
242
                   (define bar 2)
 
243
                   (+ foo bar))))
 
244
(assert-error  (tn)
 
245
               (lambda ()
 
246
                 ((lambda ()
 
247
                    (define foo 1)
 
248
                    (set! foo 5)
 
249
                    (define bar 2)
 
250
                    (+ foo bar)))))
 
251
(assert-error  (tn)
 
252
               (lambda ()
 
253
                 (define (f)
 
254
                   (define foo 1)
 
255
                   (set! foo 5)
 
256
                   (define bar 2)
 
257
                   (+ foo bar))
 
258
                 (f)))
 
259
 
 
260
(tn "internal defintions: non-beginning of block (in begin)")
 
261
(assert-error  (tn)
 
262
               (lambda ()
 
263
                 (let ()
 
264
                   (define foo 1)
 
265
                   (set! foo 5)
 
266
                   (begin
 
267
                     (define bar 2))
 
268
                   (+ foo bar))))
 
269
(assert-error  (tn)
 
270
               (lambda ()
 
271
                 (let* ()
 
272
                   (define foo 1)
 
273
                   (set! foo 5)
 
274
                   (begin
 
275
                     (define bar 2))
 
276
                   (+ foo bar))))
 
277
(assert-error  (tn)
 
278
               (lambda ()
 
279
                 (letrec ()
 
280
                   (define foo 1)
 
281
                   (set! foo 5)
 
282
                   (begin
 
283
                     (define bar 2))
 
284
                   (+ foo bar))))
 
285
(assert-error  (tn)
 
286
               (lambda ()
 
287
                 ((lambda ()
 
288
                    (define foo 1)
 
289
                    (set! foo 5)
 
290
                    (begin
 
291
                      (define bar 2))
 
292
                    (+ foo bar)))))
 
293
(assert-error  (tn)
 
294
               (lambda ()
 
295
                 (define (f)
 
296
                   (define foo 1)
 
297
                   (set! foo 5)
 
298
                   (begin
 
299
                     (define bar 2))
 
300
                   (+ foo bar))
 
301
                 (f)))
 
302
 
 
303
(tn "internal defintions: non-beginning of block (in eval)")
 
304
(assert-equal? (tn)
 
305
               7
 
306
               (let ()
 
307
                 (define foo 1)
 
308
                 (set! foo 5)
 
309
                 (eval '(define bar 2)
 
310
                       (interaction-environment))
 
311
                 (+ foo bar)))
 
312
(assert-equal? (tn)
 
313
               7
 
314
               (let* ()
 
315
                 (define foo 1)
 
316
                 (set! foo 5)
 
317
                 (eval '(define bar 2)
 
318
                       (interaction-environment))
 
319
                 (+ foo bar)))
 
320
(assert-equal? (tn)
 
321
               7
 
322
               (letrec ()
 
323
                 (define foo 1)
 
324
                 (set! foo 5)
 
325
                 (eval '(define bar 2)
 
326
                       (interaction-environment))
 
327
                 (+ foo bar)))
 
328
(assert-equal? (tn)
 
329
               7
 
330
               ((lambda ()
 
331
                  (define foo 1)
 
332
                  (set! foo 5)
 
333
                  (eval '(define bar 2)
 
334
                        (interaction-environment))
 
335
                  (+ foo bar))))
 
336
(assert-equal? (tn)
 
337
               7
 
338
               (let ()
 
339
                 (define (f)
 
340
                   (define foo 1)
 
341
                   (set! foo 5)
 
342
                   (eval '(define bar 2)
 
343
                         (interaction-environment))
 
344
                   (+ foo bar))
 
345
                 (f)))
 
346
 
 
347
;; As specified as follows in R5RS, definitions in following forms are invalid.
 
348
;;
 
349
;; 5.2 Definitions
 
350
;;
 
351
;; Definitions are valid in some, but not all, contexts where expressions are
 
352
;; allowed. They are valid only at the top level of a <program> and at the
 
353
;; beginning of a <body>.
 
354
;;
 
355
;; 5.2.2 Internal definitions
 
356
;;
 
357
;; Definitions may occur at the beginning of a <body> (that is, the body of a
 
358
;; lambda, let, let*, letrec, let-syntax, or letrec-syntax expression or that
 
359
;; of a definition of an appropriate form).
 
360
;;
 
361
;; Wherever an internal definition may occur (begin <definition1> ...) is
 
362
;; equivalent to the sequence of definitions that form the body of the begin.
 
363
(tn "definition in do")
 
364
(assert-error (tn)
 
365
              (lambda ()
 
366
                (do ((i 0 (+ i 1)))
 
367
                    ((= i 1) (+ x 3))
 
368
                  (define x 6))))
 
369
(assert-error (tn)
 
370
              (lambda ()
 
371
                (do ((i 0 (+ i 1)))
 
372
                    ((= i 1) (+ x 3))
 
373
                  (begin
 
374
                    (define x 6)))))
 
375
(assert-equal? (tn)
 
376
               9
 
377
               (do ((i 0 (+ i 1)))
 
378
                   ((= i 1) (+ x 3))
 
379
                 (eval '(define x 6)
 
380
                       (interaction-environment))))
 
381
(tn "definition in if")
 
382
(assert-error  (tn)
 
383
               (lambda ()
 
384
                 (if #t
 
385
                     (define x 6))))
 
386
(assert-error  (tn)
 
387
               (lambda ()
 
388
                 (if #t
 
389
                     (begin
 
390
                       (define x 6)))))
 
391
(assert-equal? (tn)
 
392
               'x
 
393
               (if #t
 
394
                   (eval '(define x 6)
 
395
                         (interaction-environment))))
 
396
 
 
397
;; 'begin' is treated as if transparent, as described as the third rule of
 
398
;; above.
 
399
(tn "definition in begin")
 
400
(assert-equal? (tn)
 
401
               3
 
402
               (let ()
 
403
                 (begin
 
404
                   (define foo 1)
 
405
                   (define bar 2)
 
406
                   (+ foo bar))))
 
407
(assert-equal? (tn)
 
408
               3
 
409
               (let* ()
 
410
                 (begin
 
411
                   (define foo 1)
 
412
                   (define bar 2)
 
413
                   (+ foo bar))))
 
414
(assert-equal? (tn)
 
415
               3
 
416
               (letrec ()
 
417
                 (begin
 
418
                   (define foo 1)
 
419
                   (define bar 2)
 
420
                   (+ foo bar))))
 
421
(assert-equal? (tn)
 
422
               3
 
423
               ((lambda ()
 
424
                  (begin
 
425
                    (define foo 1)
 
426
                    (define bar 2)
 
427
                    (+ foo bar)))))
 
428
(assert-equal? (tn)
 
429
               3
 
430
               (let ()
 
431
                 (define (f)
 
432
                   (begin
 
433
                     (define foo 1)
 
434
                     (define bar 2)
 
435
                     (+ foo bar)))
 
436
                 (f)))
 
437
(tn "definition in sequencial begin")
 
438
(assert-equal? (tn)
 
439
               3
 
440
               (let ()
 
441
                 (begin
 
442
                   (define foo 4)
 
443
                   (define bar 5))
 
444
                 (begin
 
445
                   (define foo 1)
 
446
                   (define bar 2)
 
447
                   (+ foo bar))))
 
448
(assert-equal? (tn)
 
449
               3
 
450
               (let* ()
 
451
                 (begin
 
452
                   (define foo 4)
 
453
                   (define bar 5))
 
454
                 (begin
 
455
                   (define foo 1)
 
456
                   (define bar 2)
 
457
                   (+ foo bar))))
 
458
(assert-equal? (tn)
 
459
               3
 
460
               (letrec ()
 
461
                 (begin
 
462
                   (define foo 4)
 
463
                   (define bar 5))
 
464
                 (begin
 
465
                   (define foo 1)
 
466
                   (define bar 2)
 
467
                   (+ foo bar))))
 
468
(assert-equal? (tn)
 
469
               3
 
470
               ((lambda ()
 
471
                  (begin
 
472
                    (define foo 4)
 
473
                    (define bar 5))
 
474
                  (begin
 
475
                    (define foo 1)
 
476
                    (define bar 2)
 
477
                    (+ foo bar)))))
 
478
(assert-equal? (tn)
 
479
               3
 
480
               (let ()
 
481
                 (define (f)
 
482
                   (begin
 
483
                     (define foo 4)
 
484
                     (define bar 5))
 
485
                   (begin
 
486
                     (define foo 1)
 
487
                     (define bar 2)
 
488
                     (+ foo bar)))
 
489
                 (f)))
 
490
(tn "definition in sequencial nested begin")
 
491
(assert-equal? (tn)
 
492
               3
 
493
               (let ()
 
494
                 (begin
 
495
                   (define foo 4)
 
496
                   (define bar 5))
 
497
                 (begin
 
498
                   (define foo 6)
 
499
                   (begin
 
500
                     (define foo 1)
 
501
                     (define bar 2))
 
502
                   (+ foo bar))))
 
503
(assert-equal? (tn)
 
504
               3
 
505
               (let* ()
 
506
                 (begin
 
507
                   (define foo 4)
 
508
                   (define bar 5))
 
509
                 (begin
 
510
                   (define foo 6)
 
511
                   (begin
 
512
                     (define foo 1)
 
513
                     (define bar 2))
 
514
                   (+ foo bar))))
 
515
(assert-equal? (tn)
 
516
               3
 
517
               (letrec ()
 
518
                 (begin
 
519
                   (define foo 4)
 
520
                   (define bar 5))
 
521
                 (begin
 
522
                   (define foo 6)
 
523
                   (begin
 
524
                     (define foo 1)
 
525
                     (define bar 2))
 
526
                   (+ foo bar))))
 
527
(assert-equal? (tn)
 
528
               3
 
529
               ((lambda ()
 
530
                  (begin
 
531
                    (define foo 4)
 
532
                    (define bar 5))
 
533
                  (begin
 
534
                    (define foo 1)
 
535
                    (define bar 2)
 
536
                    (+ foo bar)))))
 
537
(assert-equal? (tn)
 
538
               3
 
539
               (let ()
 
540
                 (define (f)
 
541
                   (begin
 
542
                     (define foo 4)
 
543
                     (define bar 5))
 
544
                   (begin
 
545
                     (define foo 6)
 
546
                     (begin
 
547
                       (define foo 1)
 
548
                       (define bar 2))
 
549
                     (+ foo bar)))
 
550
                 (f)))
 
551
(tn "definition in invalid sequencial begin")
 
552
(assert-error  (tn)
 
553
               (lambda ()
 
554
                 (let ()
 
555
                   (begin
 
556
                     (define foo 4)
 
557
                     (define bar 5)
 
558
                     (set! foo 3))
 
559
                   (begin
 
560
                     (define foo 1)
 
561
                     (define bar 2)
 
562
                     (+ foo bar)))))
 
563
(assert-error  (tn)
 
564
               (lambda ()
 
565
                 (let* ()
 
566
                   (begin
 
567
                     (define foo 4)
 
568
                     (define bar 5)
 
569
                     (set! foo 3))
 
570
                   (begin
 
571
                     (define foo 1)
 
572
                     (define bar 2)
 
573
                     (+ foo bar)))))
 
574
(assert-error  (tn)
 
575
               (lambda ()
 
576
                 (letrec ()
 
577
                   (begin
 
578
                     (define foo 4)
 
579
                     (define bar 5)
 
580
                     (set! foo 3))
 
581
                   (begin
 
582
                     (define foo 1)
 
583
                     (define bar 2)
 
584
                     (+ foo bar)))))
 
585
(assert-error  (tn)
 
586
               (lambda ()
 
587
                 ((lambda ()
 
588
                    (begin
 
589
                      (define foo 4)
 
590
                      (define bar 5)
 
591
                      (set! foo 3))
 
592
                    (begin
 
593
                      (define foo 1)
 
594
                      (define bar 2)
 
595
                      (+ foo bar))))))
 
596
(assert-error  (tn)
 
597
               (lambda ()
 
598
                 (let ()
 
599
                   (define (f)
 
600
                     (begin
 
601
                       (define foo 4)
 
602
                       (define bar 5)
 
603
                       (set! foo 3))
 
604
                     (begin
 
605
                       (define foo 1)
 
606
                       (define bar 2)
 
607
                       (+ foo bar)))
 
608
                   (f))))
 
609
 
 
610
; set!
 
611
(define (set-dot a . b)
 
612
  (set! b '(1 2))
 
613
  b)
 
614
 
 
615
(assert-equal? "set dot test" '(1 2) (set-dot '()))
 
616
 
 
617
(if (and (provided? "sigscheme")
 
618
         (provided? "strict-argcheck"))
 
619
    (begin
 
620
      (tn "define function form: boolean as an arg")
 
621
      (assert-error (tn) (lambda () (define (f . #t) #t)))
 
622
      (assert-error (tn) (lambda () (define (f #t) #t)))
 
623
      (assert-error (tn) (lambda () (define (f x #t) #t)))
 
624
      (assert-error (tn) (lambda () (define (f #t x) #t)))
 
625
      (assert-error (tn) (lambda () (define (f x . #t) #t)))
 
626
      (assert-error (tn) (lambda () (define (f #t . x) #t)))
 
627
      (assert-error (tn) (lambda () (define (f x y #t) #t)))
 
628
      (assert-error (tn) (lambda () (define (f x y . #t) #t)))
 
629
      (assert-error (tn) (lambda () (define (f x #t y) #t)))
 
630
      (assert-error (tn) (lambda () (define (f x #t . y) #t)))
 
631
      (tn "define function form: intger as an arg")
 
632
      (assert-error (tn) (lambda () (define (f . 1) #t)))
 
633
      (assert-error (tn) (lambda () (define (f 1) #t)))
 
634
      (assert-error (tn) (lambda () (define (f x 1) #t)))
 
635
      (assert-error (tn) (lambda () (define (f 1 x) #t)))
 
636
      (assert-error (tn) (lambda () (define (f x . 1) #t)))
 
637
      (assert-error (tn) (lambda () (define (f 1 . x) #t)))
 
638
      (assert-error (tn) (lambda () (define (f x y 1) #t)))
 
639
      (assert-error (tn) (lambda () (define (f x y . 1) #t)))
 
640
      (assert-error (tn) (lambda () (define (f x 1 y) #t)))
 
641
      (assert-error (tn) (lambda () (define (f x 1 . y) #t)))
 
642
      (tn "define function form: null as an arg")
 
643
      (assert-true  (tn)            (define (f . ()) #t))
 
644
      (assert-error (tn) (lambda () (define (f ()) #t)))
 
645
      (assert-error (tn) (lambda () (define (f x ()) #t)))
 
646
      (assert-error (tn) (lambda () (define (f () x) #t)))
 
647
      (assert-true  (tn)            (define (f x . ()) #t))
 
648
      (assert-error (tn) (lambda () (define (f () . x) #t)))
 
649
      (assert-error (tn) (lambda () (define (f x y ()) #t)))
 
650
      (assert-true  (tn)            (define (f x y . ()) #t))
 
651
      (assert-error (tn) (lambda () (define (f x () y) #t)))
 
652
      (assert-error (tn) (lambda () (define (f x () . y) #t)))
 
653
      (tn "define function form: pair as an arg")
 
654
      (assert-true  (tn)            (define (f . (a)) #t))
 
655
      (assert-error (tn) (lambda () (define (f (a)) #t)))
 
656
      (assert-error (tn) (lambda () (define (f x (a)) #t)))
 
657
      (assert-error (tn) (lambda () (define (f (a) x) #t)))
 
658
      (assert-true  (tn)            (define (f x . (a)) #t))
 
659
      (assert-error (tn) (lambda () (define (f (a) . x) #t)))
 
660
      (assert-error (tn) (lambda () (define (f x y (a)) #t)))
 
661
      (assert-true  (tn)            (define (f x y . (a)) #t))
 
662
      (assert-error (tn) (lambda () (define (f x (a) y) #t)))
 
663
      (assert-error (tn) (lambda () (define (f x (a) . y) #t)))
 
664
      (tn "define function form: char as an arg")
 
665
      (assert-error (tn) (lambda () (define (f . #\a) #t)))
 
666
      (assert-error (tn) (lambda () (define (f #\a) #t)))
 
667
      (assert-error (tn) (lambda () (define (f x #\a) #t)))
 
668
      (assert-error (tn) (lambda () (define (f #\a x) #t)))
 
669
      (assert-error (tn) (lambda () (define (f x . #\a) #t)))
 
670
      (assert-error (tn) (lambda () (define (f #\a . x) #t)))
 
671
      (assert-error (tn) (lambda () (define (f x y #\a) #t)))
 
672
      (assert-error (tn) (lambda () (define (f x y . #\a) #t)))
 
673
      (assert-error (tn) (lambda () (define (f x #\a y) #t)))
 
674
      (assert-error (tn) (lambda () (define (f x #\a . y) #t)))
 
675
      (tn "define function form: string as an arg")
 
676
      (assert-error (tn) (lambda () (define (f . "a") #t)))
 
677
      (assert-error (tn) (lambda () (define (f "a") #t)))
 
678
      (assert-error (tn) (lambda () (define (f x "a") #t)))
 
679
      (assert-error (tn) (lambda () (define (f "a" x) #t)))
 
680
      (assert-error (tn) (lambda () (define (f x . "a") #t)))
 
681
      (assert-error (tn) (lambda () (define (f "a" . x) #t)))
 
682
      (assert-error (tn) (lambda () (define (f x y "a") #t)))
 
683
      (assert-error (tn) (lambda () (define (f x y . "a") #t)))
 
684
      (assert-error (tn) (lambda () (define (f x "a" y) #t)))
 
685
      (assert-error (tn) (lambda () (define (f x "a" . y) #t)))
 
686
      (tn "define function form: vector as an arg")
 
687
      (assert-error (tn) (lambda () (define (f . #(a)) #t)))
 
688
      (assert-error (tn) (lambda () (define (f #(a)) #t)))
 
689
      (assert-error (tn) (lambda () (define (f x #(a)) #t)))
 
690
      (assert-error (tn) (lambda () (define (f #(a) x) #t)))
 
691
      (assert-error (tn) (lambda () (define (f x . #(a)) #t)))
 
692
      (assert-error (tn) (lambda () (define (f #(a) . x) #t)))
 
693
      (assert-error (tn) (lambda () (define (f x y #(a)) #t)))
 
694
      (assert-error (tn) (lambda () (define (f x y . #(a)) #t)))
 
695
      (assert-error (tn) (lambda () (define (f x #(a) y) #t)))
 
696
      (assert-error (tn) (lambda () (define (f x #(a) . y) #t)))))
 
697
 
 
698
(total-report)