From 93355b06a8270f02d345bdbe7b6a8c1bea9789bb Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Thu, 28 Sep 2023 14:34:11 +0200 Subject: Reduced the number of error messages --- test/qsp_parser_test.ml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml index 25619b7..c37c7f1 100644 --- a/test/qsp_parser_test.ml +++ b/test/qsp_parser_test.ml @@ -689,6 +689,43 @@ let test_input () = Tree.Ast.Literal (_position, "") )); ] +let test_mutiple_inline_ifs () = + _test_instruction "if 1 > 0: 1 else if 1 < 0: 0" + [ + Tree.Ast.If + { + loc = _position; + then_ = + ( _position, + Tree.Ast.BinaryOp + ( _position, + Gt, + Tree.Ast.Integer (_position, "1"), + Tree.Ast.Integer (_position, "0") ), + [ Tree.Ast.Expression (Tree.Ast.Integer (_position, "1")) ] ); + elifs = []; + else_ = + [ + Tree.Ast.If + { + loc = _position; + then_ = + ( _position, + Tree.Ast.BinaryOp + ( _position, + Lt, + Tree.Ast.Integer (_position, "1"), + Tree.Ast.Integer (_position, "0") ), + [ + Tree.Ast.Expression (Tree.Ast.Integer (_position, "0")); + ] ); + elifs = []; + else_ = []; + }; + ]; + }; + ] + let syntax = ( "Syntax", [ @@ -750,6 +787,7 @@ let syntax = Alcotest.test_case "Operator2" `Quick test_operator2; Alcotest.test_case "Dyneval" `Quick test_dyneval; Alcotest.test_case "Input" `Quick test_input; + Alcotest.test_case "inline if else if" `Quick test_mutiple_inline_ifs; ] ) let () = Alcotest.run "qsp_parser" [ syntax ] -- cgit v1.2.3