diff options
Diffstat (limited to 'test/syntax.ml')
-rw-r--r-- | test/syntax.ml | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/syntax.ml b/test/syntax.ml index 9aca3b6..a420035 100644 --- a/test/syntax.ml +++ b/test/syntax.ml @@ -1,9 +1,14 @@ -module Parser = Qparser.Parser.Make (Qsp_syntax.Tree) module Tree = Qsp_syntax.Tree -module Ast = Qsp_syntax.Tree.Ast -module T = Ast +module Ast = Tree.Ast +module Check = Qsp_syntax.Check module S = Qsp_syntax.S +let _, _, location_id, e1 = Check.build (module Tree) + +module Parser = Check.Make (struct + let t = [| e1 |] +end) + let _position = (Lexing.dummy_pos, Lexing.dummy_pos) type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show] @@ -21,7 +26,11 @@ let parse : string -> (S.pos location, Qsp_syntax.Report.t) result = let lexing = Sedlexing.Latin1.from_string content |> Qparser.Lexbuf.from_lexbuf in - Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing |> Result.map fst + Qparser.Analyzer.parse (module Parser) lexing + |> Result.map (fun (location, _report) -> + (* Uncatched excteptions here, but we are in the tests… + If it’s fail here I have an error in the code. *) + Array.get location 0 |> Check.get location_id |> Option.get) let location : S.pos location Alcotest.testable = let equal = equal_location (fun _ _ -> true) in @@ -113,7 +122,7 @@ let test_set_array_append () = let test_direct_assignation () = let index = None in - let var = { T.pos = _position; name = "VALUE"; index } in + let var = { Ast.pos = _position; name = "VALUE"; index } in _test_instruction "value = '123'" Ast.[ Declaration (_position, var, Eq', Literal (_position, "123")) ] |