blob: 23a9cfc5b7e3313d4cce1e92af9984a2cbbbb08f (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
(import (scheme base)
(only (csc ir1)
constant-expression
constant?
ir1=?
lexical-ref-name
lexical-ref?
lexical-set-expression
lexical-set-name
lexical-set?
make-constant
make-lambda-case
void?)
(only (csc testing)
assert-equal
test)
(csc macros))
(test builtin-quote
(assert-equal ir1=?
(make-constant '(test 1 2 3))
(expand '(quote (test 1 2 3)) builtins-environment)))
(test builtin-syntax-rules-literal
(assert-equal ir1=?
(make-constant 1)
(expand
'(builtin-let-syntax
(foo
(syntax-rules (a b)
((foo a)
0)
((foo b)
1)))
(foo b))
builtins-environment)))
(test builtin-syntax-rules-underscore
(assert-equal ir1=?
(make-constant 0)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo _) 0)))
(foo ignored))
builtins-environment)))
(test builtin-syntax-rules-substitution
(assert-equal ir1=?
(make-constant 5)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo x) x)))
(foo 5))
builtins-environment)))
(test builtin-syntax-rules-nil
(assert-equal ir1=?
(make-constant 1)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo x) 0)
((foo) 1)))
(foo))
builtins-environment)))
(test builtin-syntax-rules-improper-list
(assert-equal ir1=?
(make-constant 1)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo a . b) a)))
(foo 1 2 3))
builtins-environment)))
(test builtin-syntax-rules-quoted
(assert-equal ir1=?
(make-constant 'a)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo x) (quote x))))
(foo a))
builtins-environment)))
(test builtin-syntax-rules-constant
(assert-equal ir1=?
(make-constant 2)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo "abc") 0)
((foo "def") 1)
((foo "ghi") 2)))
(foo "ghi"))
builtins-environment)))
(test builtin-syntax-rules-ellipsis
(assert-equal ir1=?
(make-constant 5)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo x ...) (x ...))))
(foo quote 5))
builtins-environment)))
(test builtin-syntax-rules-ellipsis-improper
(assert-equal ir1=?
(make-constant 5)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ()
((foo x ... . y) (x ... y))))
(foo quote . 5))
builtins-environment)))
(test builtin-syntax-rules-ellipsis-zip
(assert-equal ir1=?
(make-constant '((1 . 3) (2 . 4)))
(expand
'(builtin-let-syntax
(zip
(syntax-rules ()
((zip (x ...) (y ...))
(quote ((x . y) ...)))))
(zip (1 2) (3 4)))
builtins-environment)))
(test builtin-syntax-rules-ellipsis-nested
(assert-equal ir1=?
(make-constant '(1 2 3 4 5))
(expand
'(builtin-let-syntax
(append
(syntax-rules ()
((append (x ...) ...)
(quote (x ... ...)))))
(append (1 2) (3 4) () (5)))
builtins-environment)))
(test builtin-syntax-rules-ellipsis-custom
(assert-equal ir1=?
(make-constant 5)
(expand
'(builtin-let-syntax
(foo
(syntax-rules ::: ()
((foo x :::) (x :::))))
(foo quote 5))
builtins-environment)))
(test builtin-case-lambda
(assert-equal ir1=?
(make-lambda-case '(x y z) #f #f (make-constant 5)
(make-lambda-case '(a b c) 'd #f (make-constant 6) '()))
(expand
'(case-lambda
((x y z) (quote 5))
((a b c . d) (quote 6)))
builtins-environment)))
|