Add tests Path.descendent
Some of them are failing because it it doesn't work when the paths are equal or have the same length
This commit is contained in:
parent
feaca3058b
commit
9e4390ddc4
|
@ -37,3 +37,10 @@
|
|||
(glob_files ${SCOPE_ROOT}/src/*.cmi)
|
||||
(glob_files ${SCOPE_ROOT}/vendor/re/*.cmi)))
|
||||
(action (chdir ${SCOPE_ROOT} (run ${exe:expect_test.exe} ${<})))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps (path.mlt
|
||||
(glob_files ${SCOPE_ROOT}/src/*.cmi)
|
||||
(glob_files ${SCOPE_ROOT}/vendor/re/*.cmi)))
|
||||
(action (chdir ${SCOPE_ROOT} (run ${exe:expect_test.exe} ${<})))))
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
(* -*- tuareg -*- *)
|
||||
|
||||
open Jbuilder;;
|
||||
open Import;;
|
||||
|
||||
let r = Path.(relative root);;
|
||||
|
||||
#install_printer Path.pp;;
|
||||
|
||||
Path.(let p = relative root "foo" in descendant p ~of_:p)
|
||||
[%%expect{|
|
||||
val r : string -> Jbuilder.Path.t = <fun>
|
||||
Exception: Invalid_argument "String.sub / Bytes.sub".
|
||||
Raised at file "pervasives.ml", line 33, characters 25-45
|
||||
Called from file "string.ml", line 47, characters 2-23
|
||||
Called from file "src/path.ml", line 193, characters 13-71
|
||||
Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
||||
|}]
|
||||
|
||||
(* different strings but same length *)
|
||||
Path.(descendant (relative root "foo") ~of_:(relative root "bar"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "index out of bounds".
|
||||
Raised by primitive operation at file "src/path.ml", line 192, characters 29-39
|
||||
Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
||||
|}]
|
||||
|
||||
Path.(descendant (r "foo") ~of_:(r "foo/"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "String.sub / Bytes.sub".
|
||||
Raised at file "pervasives.ml", line 33, characters 25-45
|
||||
Called from file "string.ml", line 47, characters 2-23
|
||||
Called from file "src/path.ml", line 193, characters 13-71
|
||||
Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
||||
|}]
|
||||
|
||||
Path.(descendant (r "foo/") ~of_:(r "foo"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "String.sub / Bytes.sub".
|
||||
Raised at file "pervasives.ml", line 33, characters 25-45
|
||||
Called from file "string.ml", line 47, characters 2-23
|
||||
Called from file "src/path.ml", line 193, characters 13-71
|
||||
Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
||||
|}]
|
||||
|
||||
Path.(descendant (r "foo/bar") ~of_:(r "foo"))
|
||||
[%%expect{|
|
||||
- : Jbuilder.Path.t option = Some bar
|
||||
|}]
|
||||
|
||||
Path.(descendant Path.root ~of_:(r "foo"))
|
||||
[%%expect{|
|
||||
- : Jbuilder.Path.t option = None
|
||||
|}]
|
||||
|
||||
Path.(descendant Path.root ~of_:Path.root)
|
||||
[%%expect{|
|
||||
- : Jbuilder.Path.t option = Some
|
||||
|}]
|
||||
|
||||
Path.(descendant (r "foo") ~of_:Path.root)
|
||||
[%%expect{|
|
||||
- : Jbuilder.Path.t option = Some foo
|
||||
|}]
|
Loading…
Reference in New Issue