make collapse-module-path-index work on a "self" modidx

This commit is contained in:
Matthew Flatt 2017-06-01 19:36:22 -06:00
parent 3364dba903
commit f459dd9eb7
3 changed files with 16 additions and 5 deletions

View File

@ -54,20 +54,26 @@ base.
(-> module-path?))])
module-path?]
[(collapse-module-path-index [module-path-index module-path-index?])
module-path?])]{
(or/c module-path? #f)])]{
Like @racket[collapse-module-path] when given two arguments, but the
input is a @techlink[#:doc refman]{module path index}; in this case,
the @racket[rel-to-module-path-v] base is used where the module path
index contains the ``self'' index.
index contains the ``self'' index (see @racket[module-path-index-split]).
When given a single argument, @racket[collapse-module-path-index]
returns a module path that is relative if the given module path index
is relative. The resulting module path is not necessarily normalized.
is relative, except that it returns @racket[#f] if its argument is the
``self'' module path index. A resulting module path is
not necessarily normalized.
@history[#:changed "6.1.1.8" @elem{Added the one-argument variant for
collapsing a relative module path
index.}]}
index.}
#:changed "6.9.0.5" @elem{Added support for the ``self'' module
path index as the only argument, which
meant extending the result contract to
include @scheme[#f]}]}
@close-eval[evaluator]

View File

@ -10,6 +10,11 @@
(define self (module-path-index-join #f #f))
(check (collapse-module-path-index self)
#f)
(check (collapse-module-path-index self here)
here)
(define (check-collapse p expected [relative-expected expected]
#:here [here here])
(check (collapse-module-path p here)

View File

@ -32,7 +32,7 @@
. -> . simple-rel-to-module-path-v/c)]
[collapse-module-path-index (case->
(module-path-index?
. -> . module-path?)
. -> . (or/c #f module-path?))
((or/c symbol? module-path-index?)
rel-to-module-path-v/c
. -> . simple-rel-to-module-path-v/c))])