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 <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored and NathanReb committed Jan 31, 2024
1 parent edc51a4 commit 3abce85
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 @@ -101,17 +101,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 3abce85

Please sign in to comment.