diff options
author | Chimrod <> | 2023-10-07 12:24:37 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-18 09:49:47 +0200 |
commit | c2f87ff1e6e5676968804cd50b86fc2f0f9ad672 (patch) | |
tree | ab0770cc70bbe6ed26606200110cc503390ac420 /test | |
parent | a70c88bd727c7938c3d8d1355bf5474546d7d72e (diff) |
Made explicit the use of the report in the parser
Diffstat (limited to 'test')
-rw-r--r-- | test/syntax.ml | 9 | ||||
-rw-r--r-- | test/syntax_error.ml | 7 |
2 files changed, 9 insertions, 7 deletions
diff --git a/test/syntax.ml b/test/syntax.ml index be14229..487f85b 100644 --- a/test/syntax.ml +++ b/test/syntax.ml @@ -2,27 +2,28 @@ module Parser = Qparser.Parser.Make (Qsp_syntax.Tree) module Tree = Qsp_syntax.Tree module Ast = Qsp_syntax.Tree.Ast module T = Ast +module S = Qsp_syntax.S let _position = (Lexing.dummy_pos, Lexing.dummy_pos) type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show] let get_location : - (T.pos location, Qsp_syntax.Report.t) result -> T.pos location = function + (S.pos location, Qsp_syntax.Report.t) result -> S.pos location = function | Ok e -> e | Error e -> let msg = Format.asprintf "%a" Qsp_syntax.Report.pp e in raise (Failure msg) (** Run the parser with the given expression and return the result *) -let parse : string -> (T.pos location, Qsp_syntax.Report.t) result = +let parse : string -> (S.pos location, Qsp_syntax.Report.t) result = fun content -> let lexing = Sedlexing.Latin1.from_string content |> Qparser.Lexbuf.from_lexbuf in Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing -let location : T.pos location Alcotest.testable = +let location : S.pos location Alcotest.testable = let equal = equal_location (fun _ _ -> true) in let pp = pp_location (fun formater _ -> Format.fprintf formater "_position") @@ -53,7 +54,7 @@ let test_location_without_database () = ------- |} in Alcotest.(check' location ~msg ~expected ~actual) -let _test_instruction : string -> Ast.pos Ast.statement list -> unit = +let _test_instruction : string -> S.pos Ast.statement list -> unit = fun literal expected -> let expected = (_position, expected) and _location = Printf.sprintf {|# Location diff --git a/test/syntax_error.ml b/test/syntax_error.ml index fed43a7..d395dba 100644 --- a/test/syntax_error.ml +++ b/test/syntax_error.ml @@ -1,23 +1,24 @@ module Parser = Qparser.Parser.Make (Qsp_syntax.Tree) module Ast = Qsp_syntax.Tree.Ast +module S = Qsp_syntax.S let _position = (Lexing.dummy_pos, Lexing.dummy_pos) type 'a report = { level : Qsp_syntax.Report.level; loc : 'a; message : string } [@@deriving eq, show] -let report : Ast.pos report Alcotest.testable = +let report : S.pos report Alcotest.testable = let equal = equal_report (fun _ _ -> true) in let pp = pp_report (fun formater _ -> Format.fprintf formater "_position") in Alcotest.testable pp equal let get_report : - (Ast.pos Syntax.location, Qsp_syntax.Report.t) result -> Ast.pos report = + (S.pos Syntax.location, Qsp_syntax.Report.t) result -> S.pos report = function | Ok _ -> failwith "No error" | Error { level; loc; message } -> { level; loc; message } -let _test_instruction : string -> Ast.pos report -> unit = +let _test_instruction : string -> S.pos report -> unit = fun literal expected -> let _location = Printf.sprintf {|# Location %s |