forked from philhofer/distill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contract-test.scm
42 lines (36 loc) · 968 Bytes
/
contract-test.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(include "contract.mod.scm")
(import
scheme
(distill contract))
(include "test-helpers.scm")
(define-syntax yes
(syntax-rules ()
((_ args* ...)
(begin
(test eq? #t args*) ...))))
(define-syntax no
(syntax-rules ()
((_ args* ...)
(begin
(test eq? #f args*) ...))))
(yes
((vector/c string? symbol? list?)
(vector "foo" 'foo '()))
((list/c string? symbol? list?)
(list "foo" 'foo '(x y z)))
((and/c integer? number?) 3)
((or/c symbol? number?) 3.5)
((or/c symbol? number?) 'foo)
((or/c (eq?/c 'foo) (eq?/c 'bar)) 'foo)
((or/c (eq?/c 'foo) (eq?/c 'bar)) 'bar)
((pair-of (eq?/c 'foo) (eq?/c 'bar)) (cons 'foo 'bar)))
(no
((vector/c string? symbol? list?)
(vector "foo" 'foo))
((vector/c string? symbol? list?)
(vector 'foo '()))
((list/c string? symbol? list?)
(list "foo" 'foo '() 'extra))
((and/c integer? number?) 3.5)
((or/c symbol? integer?) "nope")
((pair-of symbol? integer?) (cons 'yes 3.14159)))