From fd02a44392304986a756e7d06f8142538b386529 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Thu, 2 Nov 2023 17:35:49 +0100 Subject: Added a new checkers for unecessary use of strig containing an escaped expression --- test/nested_string.ml | 27 +++++++++++++++++++++++++++ test/qsp_parser_test.ml | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/nested_string.ml (limited to 'test') diff --git a/test/nested_string.ml b/test/nested_string.ml new file mode 100644 index 0000000..b121667 --- /dev/null +++ b/test/nested_string.ml @@ -0,0 +1,27 @@ +module Check = Make_checkTest.M (Qsp_syntax.Nested_strings) + +let _position = (Lexing.dummy_pos, Lexing.dummy_pos) + +let _test_instruction : string -> Qsp_syntax.Report.t list -> unit = + Check._test_instruction + +let nothing () = _test_instruction {| +"value = <<$variable>>" + |} [] + +let simple_expression () = + _test_instruction {|"<<$variable>>"|} + [ + { + level = Debug; + loc = _position; + message = "This expression can be simplified"; + }; + ] + +let test = + ( "Nested_strings checker", + [ + Alcotest.test_case "Ok" `Quick nothing; + Alcotest.test_case "Simple expression" `Quick simple_expression; + ] ) diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml index 7fd5b52..a86df13 100644 --- a/test/qsp_parser_test.ml +++ b/test/qsp_parser_test.ml @@ -1,5 +1,10 @@ let () = Alcotest.run "qsp_parser" [ - Syntax.test; Literals.test; Syntax_error.test; Type_of.test; Dead_end.test; + Syntax.test; + Literals.test; + Syntax_error.test; + Type_of.test; + Dead_end.test; + Nested_string.test; ] -- cgit v1.2.3