Merge pull request #765 from rgrinberg/add-spec-path
Fix off by 1 error in descendent check
This commit is contained in:
commit
a80a6f18b2
|
@ -206,7 +206,7 @@ module Local = struct
|
|||
let of_len = String.length of_ in
|
||||
let t_len = String.length t in
|
||||
(t_len = of_len && t = of_) ||
|
||||
(t_len >= of_len && t.[of_len] = '/' && String.is_prefix t ~prefix:of_)
|
||||
(t_len > of_len && t.[of_len] = '/' && String.is_prefix t ~prefix:of_)
|
||||
|
||||
let reach t ~from =
|
||||
let rec loop t from =
|
||||
|
|
|
@ -20,6 +20,71 @@ Path.(descendant (relative root "foo") ~of_:(relative root "bar"))
|
|||
- : Stdune.Path.t option = None
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "foo"))
|
||||
[%%expect{|
|
||||
- : bool = true
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "foo/"))
|
||||
[%%expect{|
|
||||
- : bool = true
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo/") ~of_:(r "foo"))
|
||||
[%%expect{|
|
||||
- : bool = true
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "bar"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "bar/"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo/") ~of_:(r "bar"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "glob/foo") ~of_:(r "glob"))
|
||||
[%%expect{|
|
||||
- : bool = true
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "glob/foo") ~of_:(r "glob/"))
|
||||
[%%expect{|
|
||||
- : bool = true
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (Path.absolute "/foo/bar") ~of_:(Path.absolute "/foo"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (Path.absolute "/foo/bar") ~of_:(Path.absolute "/foo/bar"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (Path.absolute "/foo/bar") ~of_:(Path.absolute "/foo/bar/"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (Path.absolute "/foo/bar/") ~of_:(Path.absolute "/foo/bar"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (Path.absolute "/foo/bar") ~of_:(Path.absolute "/"))
|
||||
[%%expect{|
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(descendant (r "foo") ~of_:(r "foo/"))
|
||||
[%%expect{|
|
||||
- : Stdune.Path.t option = Some foo
|
||||
|
|
Loading…
Reference in New Issue