diff options
author | Chimrod <> | 2023-10-15 18:23:01 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-15 19:04:36 +0200 |
commit | a7e382aa2b31a4ec044bda12155818c22b33d989 (patch) | |
tree | 2aa25c8ba2d5653c677ce62c5515cc5c0c98ff6f /test | |
parent | 617d2ee554ccf502c718391aa05b7b72668b83e7 (diff) |
New errors reported
Diffstat (limited to 'test')
-rw-r--r-- | test/syntax_error.ml | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/test/syntax_error.ml b/test/syntax_error.ml index e9e3fca..fed43a7 100644 --- a/test/syntax_error.ml +++ b/test/syntax_error.ml @@ -75,29 +75,18 @@ let act_no_column () = message = "Invalid `ACT` label. You probably missed a ':'"; } -let missing_ampersand_1 () = - _test_instruction "b = 1 a = 2" - { - level = Error; - loc = _position; - message = "Missing separator between instructions"; - } - -let missing_ampersand_2 () = - _test_instruction "let b = 1 a = 2" - { - level = Error; - loc = _position; - message = "Missing separator between instructions"; - } - -let missing_ampersand_3 () = - _test_instruction "set b = 1 a = 2" +let missing_ampersand () = + let result = { level = Error; loc = _position; message = "Missing separator between instructions"; } + in + let () = _test_instruction "b = 1 a = 2" result + and () = _test_instruction "let b = 1 a = 2" result + and () = _test_instruction "set b = 1 a = 2" result in + () let unclose_comment () = _test_instruction {| ! that's it|} @@ -107,6 +96,18 @@ let syntax_error () = _test_instruction {|*clr $ cla|} { level = Error; loc = _position; message = "Unexpected character \"\"" } +let missing_operand () = + let result = + { level = Error; loc = _position; message = "Missing operand" } + in + let () = _test_instruction {|if and other: 1|} result + and () = _test_instruction {|a = and other: 1|} result in + () + +let unknow_function () = + _test_instruction "a = ran(1, 2)" + { level = Error; loc = _position; message = "Unexpected expression here." } + let test = ( "Syntax Errors", [ @@ -114,9 +115,9 @@ let test = Alcotest.test_case "elseif" `Quick elseif_no_column; Alcotest.test_case "(1" `Quick unclosed_paren; Alcotest.test_case "act 1" `Quick act_no_column; - Alcotest.test_case "no &" `Quick missing_ampersand_1; - Alcotest.test_case "no &" `Quick missing_ampersand_2; - Alcotest.test_case "no &" `Quick missing_ampersand_3; + Alcotest.test_case "no &" `Quick missing_ampersand; Alcotest.test_case "unclose_comment" `Quick unclose_comment; Alcotest.test_case "Syntax error $" `Quick syntax_error; + Alcotest.test_case "Missing operand" `Quick missing_operand; + Alcotest.test_case "Unknown function" `Quick unknow_function; ] ) |