aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChimrod <>2023-09-27 13:31:14 +0200
committerChimrod <>2023-09-29 10:00:21 +0200
commit40f7b4c7398db2b832b71e3dfb8afb53116fad51 (patch)
treefc36e0fe685a3c1bc36a6d8821fbdd369d75a40c /test
parent46fd5a31d2e07b9df10d07dd900b529aca06a795 (diff)
Switched to sedlex instead of ocamllex
Diffstat (limited to 'test')
-rw-r--r--test/dune1
-rw-r--r--test/qsp_parser_test.ml10
2 files changed, 9 insertions, 2 deletions
diff --git a/test/dune b/test/dune
index 2f4e803..74546a0 100644
--- a/test/dune
+++ b/test/dune
@@ -2,6 +2,7 @@
(name qsp_parser_test)
(libraries
alcotest
+ sedlex
qparser
qsp_syntax
fmt
diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml
index b833fe5..6bf249d 100644
--- a/test/qsp_parser_test.ml
+++ b/test/qsp_parser_test.ml
@@ -7,10 +7,16 @@ let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show]
+(** Run the parser with the given expression and return the result *)
let parse : string -> T.pos location =
fun content ->
- let lexing = Lexing.from_string content in
- Parser.main Qparser.Lexer.token lexing
+ let lexing = Sedlexing.Latin1.from_string content in
+
+ match Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing with
+ | Ok e -> e
+ | Error e ->
+ let msg = Format.asprintf "%a" Qparser.Analyzer.format_error e in
+ raise (Failure msg)
let location : T.pos location Alcotest.testable =
let equal = equal_location (fun _ _ -> true) in