From 60cb98b4a27ff0f59298646c835606d0a9a47ba3 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sun, 14 Jan 2024 12:12:28 +0100 Subject: Report as a Warn error when an string is assigned in an Int variable --- test/type_of.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/type_of.ml b/test/type_of.ml index a73684a..bca7ea0 100644 --- a/test/type_of.ml +++ b/test/type_of.ml @@ -15,11 +15,21 @@ let type_mismatch () = }; ] +let type_mismatch2 () = + _test_instruction {|abc[''] = $Var|} + [ + { + level = Warn; + loc = _position; + message = "The type Integer is expected but got String"; + }; + ] + let type_conversion () = _test_instruction {|abc = '123'|} [ { - level = Debug; + level = Warn; loc = _position; message = "The type Integer is expected but got Integer as String"; }; @@ -54,6 +64,7 @@ let test = ( "Typechecking", [ Alcotest.test_case "Assign" `Quick type_mismatch; + Alcotest.test_case "Assign array" `Quick type_mismatch2; Alcotest.test_case "Conversion" `Quick type_conversion; Alcotest.test_case "Conversion'" `Quick type_conversion'; Alcotest.test_case "Comparaison" `Quick type_comparaison; -- cgit v1.2.3