syntax/modcollapse: fix to new collapse-module-path-index variant

This commit is contained in:
Matthew Flatt 2015-01-28 16:21:43 -07:00
parent 83974a42ee
commit b7e86ef6c9
3 changed files with 24 additions and 3 deletions

View File

@ -122,3 +122,24 @@
(check (collapse-module-path-index submod-submod-foo
here)
`(submod ,(build-path here-dir "foo.rkt") test))
(define dirrel (module-path-index-join
"x/banana.rkt"
self))
(check (collapse-module-path-index dirrel)
"x/banana.rkt")
(check (collapse-module-path-index dirrel
here)
(build-path here-dir "x/banana.rkt"))
(define rel-dirrel (module-path-index-join
"apple.rkt"
(module-path-index-join
"x/banana.rkt"
self)))
(check (collapse-module-path-index rel-dirrel)
"x/apple.rkt")
(check (collapse-module-path-index rel-dirrel
here)
(build-path here-dir "x" "apple.rkt"))

View File

@ -420,7 +420,7 @@ Use syntax/modcollapse instead.
;; Unix-style relative path string
(cond
[(string? prev)
(define l (drop-right (explode-relpath-string s) 1))
(define l (drop-right (explode-relpath-string prev) 1))
(if (null? l)
s
(string-join (append
@ -428,7 +428,7 @@ Use syntax/modcollapse instead.
(case e
[(same) "."]
[(up) ".."]
[else e]))
[else (path-element->string e)]))
(list s))
"/"))]
[(path? prev)

View File

@ -6,7 +6,7 @@
(define (explode-relpath-string p)
(map (lambda (p)
(cond [(assoc p '((#"." . same) (#".." . up))) => cdr]
[else (bytes->path p)]))
[else (bytes->path-element p)]))
(regexp-split #rx#"/+" (string->bytes/utf-8 p))))
(define (module-path-v-string? v)