From 4512f51dcbdc139b037554cbbf7d0183cc56b130 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 22 Dec 2019 18:08:59 +0700 Subject: [PATCH] Add tests for parsing longident's with . There are some identifiers that have the `.` character. We test cases with +. and *. Signed-off-by: Rudi Grinberg --- test/base/test.ml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/base/test.ml b/test/base/test.ml index 42cbb0b26..9898eb9ff 100644 --- a/test/base/test.ml +++ b/test/base/test.ml @@ -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")