aboutsummaryrefslogtreecommitdiff
path: root/test/make_checkTest.ml
diff options
context:
space:
mode:
authorChimrod <>2023-10-28 13:52:38 +0200
committerChimrod <>2023-11-02 11:06:12 +0100
commit872916a5661e31b655471ec0f9bf81a5474bc1ba (patch)
treedb18486f978ec97b8ddb4d4ce4e810ccd5cbf7e7 /test/make_checkTest.ml
parent8a7bdc73a7c65d23c79e1c470ba0fbff975b59a5 (diff)
Updated the tests
Diffstat (limited to 'test/make_checkTest.ml')
-rw-r--r--test/make_checkTest.ml47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/make_checkTest.ml b/test/make_checkTest.ml
new file mode 100644
index 0000000..308d309
--- /dev/null
+++ b/test/make_checkTest.ml
@@ -0,0 +1,47 @@
+let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
+
+(** Build a parser for a specific check module *)
+module M (Check : Qsp_syntax.S.Analyzer) = struct
+ module S = Qsp_syntax.S
+
+ let pp_pos = Qsp_syntax.Report.pp_pos
+
+ type pos = S.pos
+
+ let equal_pos : pos -> pos -> bool = fun _ _ -> true
+
+ type t = Qsp_syntax.Report.t = {
+ level : Qsp_syntax.Report.level;
+ loc : pos;
+ message : string;
+ }
+ [@@deriving show, eq]
+
+ let report : Qsp_syntax.Report.t list Alcotest.testable =
+ Alcotest.list @@ Alcotest.testable Qsp_syntax.Report.pp equal
+
+ let parse :
+ string ->
+ (Check.Location.t * Qsp_syntax.Report.t list, Qsp_syntax.Report.t) result
+ =
+ fun content ->
+ let lexing =
+ Sedlexing.Latin1.from_string content |> Qparser.Lexbuf.from_lexbuf
+ in
+ Qparser.Analyzer.parse (module Check) lexing
+
+ let get_report :
+ (Check.Location.t * Qsp_syntax.Report.t list, Qsp_syntax.Report.t) result ->
+ Qsp_syntax.Report.t list = function
+ | Ok (_, report) -> report
+ | Error _ -> failwith "Error"
+
+ let _test_instruction : string -> Qsp_syntax.Report.t list -> unit =
+ fun literal expected ->
+ let _location = Printf.sprintf {|# Location
+%s
+------- |} literal in
+ let actual = get_report @@ parse _location and msg = literal in
+
+ Alcotest.(check' report ~msg ~expected ~actual)
+end