12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- module Check = Make_checkTest.M (Qsp_syntax.Dead_end)
- let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
- let _test_instruction : string -> Qsp_syntax.Report.t list -> unit =
- Check._test_instruction
- (** This one is OK because act provide a solution in any case *)
- let ok () =
- _test_instruction {|
- if 0:
- act '': gt ''
- if 1:
- act '': gt ''
- end
- end
- |}
- []
- (** Ignore top level dead end*)
- let toplevel () =
- _test_instruction {|
- act 1:
- act '': gt ''
- end
- if 1: act '': gt ''
- |} []
- let else_branch () =
- _test_instruction
- {|
- if 0:
- if 1:
- act '': gt ''
- else
- act '': ''
- end
- end
- |}
- [
- {
- level = Warn;
- loc = _position;
- message = "Possible dead end (unmatched path)";
- };
- ]
- let elseif_branch () =
- _test_instruction
- {|
- if 0:
- if 1:
- act '': ''
- elseif 0:
- act '': gt ''
- end
- end
- |}
- [
- {
- level = Debug;
- loc = _position;
- message = "Possible dead end (no else fallback)";
- };
- ]
- let missing_else () =
- _test_instruction {|
- if 0:
- if 1: act '': gt ''
- end
- |}
- [
- {
- level = Debug;
- loc = _position;
- message = "Possible dead end (no else fallback)";
- };
- ]
- let nothing () = _test_instruction {|
- if 0:
- if 1: 0
- end
- |} []
- let test =
- ( "Dead end",
- [
- Alcotest.test_case "No dead_end" `Quick ok;
- Alcotest.test_case "top level" `Quick toplevel;
- Alcotest.test_case "Else branch" `Quick else_branch;
- Alcotest.test_case "ElseIf branch" `Quick elseif_branch;
- Alcotest.test_case "Missing else" `Quick missing_else;
- Alcotest.test_case "nothing" `Quick nothing;
- ] )
|