Skip to content

Commit 0c41dd9

Browse files
committed
Add test cases for provide case in parser.
1 parent 7058491 commit 0c41dd9

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

private/parser.rkt

+4-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
(syntax-parse form
293293
#:literals (quote lib file planet)
294294
[i:id (syntax-e #'i)]
295-
; [s:string (syntax-e #'s)] TODO proper string syntax calss
295+
[s:str (syntax-e #'s)]
296296
[(quote id:id) `(quote* ,(syntax-e #'id))]
297297
[(lib s ...)
298298
`(lib ,(for/list ([i (in-list (syntax->list #'(s ...)))])
@@ -305,7 +305,9 @@
305305
,(syntax-e #'s3)
306306
,(for/list ([i (in-list (syntax->list #'(s4 ...)))])
307307
(syntax-e i)) ...))]
308-
[else (syntax-e #'path)]))
308+
[else
309+
#:when (path? (syntax-e #'else))
310+
(syntax-e #'else)]))
309311

310312
(parse-phaseless-prov-spec : * (form env) -> phaseless-prov-spec ()
311313
(syntax-parse form

private/tests.rkt

+33-1
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@
187187
(#%require (only racket/match match)
188188
(all-except racket/match match)
189189
(rename racket/match match2 match)
190+
(prefix match2: racket/match)
190191
(prefix-all-except match: racket/match match)
191192
; TODO (planet "match" ("match" "match")) ; Not a real package
192193
))))
193194
`(module bar racket/base
194195
((#%require (only racket/match ,match)
195196
(all-except racket/match ,match)
196197
(rename racket/match ,match2 ,match)
198+
(prefix-all-except match2: racket/match)
197199
(prefix-all-except match: racket/match ,match)
198200
; TODO (planet "match" ("match" "match"))
199201
))))
@@ -217,7 +219,37 @@
217219
`(#%plain-app (primitive eval) (quote-syntax ,#'(+ 1 2))))
218220
(check-compiler-equal?
219221
(current-compile #`(eval (quote-syntax (+ 1 2) #:local)))
220-
`(#%plain-app (primitive eval) (quote-syntax-local ,#'(+ 1 2)))))))
222+
`(#%plain-app (primitive eval) (quote-syntax-local ,#'(+ 1 2))))
223+
(check-compiler-equal?
224+
(current-compile #'(begin
225+
(define x 5)
226+
(#%variable-reference (#%top . x))))
227+
`(begin*
228+
(define-values (,x) '5)
229+
(#%variable-reference-top ,x)))
230+
(check-compiler-equal?
231+
(current-compile #'(module foo racket/base
232+
(#%plain-module-begin
233+
(#%require (for-label racket/match))
234+
(#%provide (for-label match))
235+
(define x 5)
236+
(#%provide (protect x)))))
237+
`(module foo racket/base
238+
((#%require (for-meta #f racket/match))
239+
(#%provide (for-meta* #f ,match))
240+
(define-values (,x) '5)
241+
(#%provide (protect ,x)))))
242+
(check-compiler-equal?
243+
(current-compile #'(module foo racket/base
244+
(#%plain-module-begin
245+
(module bar racket/base
246+
(#%plain-module-begin
247+
42))
248+
(#%require (submod "." bar)))))
249+
`(module foo racket/base
250+
((submodule bar racket/base
251+
('42))
252+
(#%require (submod "." bar))))))))
221253

222254
;; ===================================================================================================
223255

0 commit comments

Comments
 (0)