nested_string.ml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. module Check = Make_checkTest.M (Qsp_syntax.Nested_strings)
  2. let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
  3. let _test_instruction : string -> Qsp_syntax.Report.t list -> unit =
  4. Check._test_instruction
  5. let report =
  6. [
  7. {
  8. Qsp_syntax.Report.level = Debug;
  9. Qsp_syntax.Report.loc = _position;
  10. Qsp_syntax.Report.message = "This expression can be simplified";
  11. };
  12. ]
  13. let nothing () = _test_instruction {|"value = <<$variable>>"|} []
  14. let string () = _test_instruction {|"<<'ABC'>>"|} report
  15. let string_variable () = _test_instruction {|"<<$variable>>"|} report
  16. (** It’s OK to use this system to convert a numeric value into a string *)
  17. let integer () = _test_instruction {|"<<123>>"|} []
  18. let integer_variable () = _test_instruction {|"<<variable>>"|} []
  19. let indexed_text () = _test_instruction {|variable['<<$variable>>']|} report
  20. let test =
  21. ( "Nested_strings checker",
  22. [
  23. Alcotest.test_case "Ok" `Quick nothing;
  24. Alcotest.test_case "String variable" `Quick string_variable;
  25. Alcotest.test_case "Integer" `Quick integer;
  26. Alcotest.test_case "String" `Quick string;
  27. Alcotest.test_case "Integer variable" `Quick integer_variable;
  28. Alcotest.test_case "Indexed text" `Quick indexed_text;
  29. ] )