Skip to content

Commit

Permalink
Add tests for parsing longident's with .
Browse files Browse the repository at this point in the history
There are some identifiers that have the `.` character. We test cases
with +. and *.

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Dec 22, 2019
1 parent 346c5ba commit 4512f51
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions test/base/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,36 @@ let _ = convert_longident "Base.( land )"

let _ = convert_longident "A(B)"
[%%expect{|
Exception: Invalid_argument "Ppxlib.Longident.parse: \"A(B)\"".
Exception: (Invalid_argument "Ppxlib.Longident.parse: \"A(B)\"")
|}]

let _ = convert_longident "A.B(C)"
[%%expect{|
Exception: Invalid_argument "Ppxlib.Longident.parse: \"A.B(C)\"".
Exception: (Invalid_argument "Ppxlib.Longident.parse: \"A.B(C)\"")
|}]

let _ = convert_longident ")"
[%%expect{|
Exception: Invalid_argument "Ppxlib.Longident.parse: \")\"".
Exception: (Invalid_argument "Ppxlib.Longident.parse: \")\"")
|}]

(* FIXME this is a bug *)
let _ = convert_longident "+."
[%%expect{|
- : string * longident =
("( + ).", Ppxlib.Longident.Ldot (Ppxlib.Longident.Lident "+", ""))
|}]

let _ = convert_longident "Foo.(+.)"
[%%expect{|
- : string * longident =
("Foo.( +. )", Ppxlib.Longident.Ldot (Ppxlib.Longident.Lident "Foo", "+."))
|}]

let _ = convert_longident "Foo.( *. )"
[%%expect{|
- : string * longident =
("Foo.( *. )", Ppxlib.Longident.Ldot (Ppxlib.Longident.Lident "Foo", "*."))
|}]

let _ = Ppxlib.Code_path.(file_path @@ top_level ~file_path:"dir/main.ml")
Expand Down

0 comments on commit 4512f51

Please sign in to comment.