diff options
| author | Chimrod <> | 2023-09-28 14:34:11 +0200 | 
|---|---|---|
| committer | Chimrod <> | 2023-09-29 10:00:21 +0200 | 
| commit | 93355b06a8270f02d345bdbe7b6a8c1bea9789bb (patch) | |
| tree | 486b89672215278d7ff1a25a853ab25e1c8d2a38 /test | |
| parent | 4efc1d21441c5e9ad7f24a3e473bbbd8025de124 (diff) | |
Reduced the number of error messages
Diffstat (limited to 'test')
| -rw-r--r-- | test/qsp_parser_test.ml | 38 | 
1 files changed, 38 insertions, 0 deletions
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 ]  | 
