diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/qsp_parser_test.ml | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml index 6ea9eab..d827099 100644 --- a/test/qsp_parser_test.ml +++ b/test/qsp_parser_test.ml @@ -256,18 +256,24 @@ let test_concat () = let content = {| $firstName + ' ' + $lastName |} in - let index = None in - let firstname = { Ast.pos = _position; name = "$FIRSTNAME"; index } - and lastName = { Ast.pos = _position; name = "$LASTNAME"; index } - and space = Ast.Literal (_position, " ") in _test_instruction content [ - Expression - (BinaryOp + Tree.Ast.Expression + (Tree.Ast.BinaryOp ( _position, Plus, - Ident firstname, - BinaryOp (_position, Plus, space, Ident lastName) )); + Tree.Ast.BinaryOp + ( _position, + Plus, + Tree.Ast.Ident + { + Tree.Ast.pos = _position; + name = "$FIRSTNAME"; + index = None; + }, + Tree.Ast.Literal (_position, " ") ), + Tree.Ast.Ident + { Tree.Ast.pos = _position; name = "$LASTNAME"; index = None } )); ] let test_comment () = _test_instruction "! Comment" [ Comment _position ] @@ -721,6 +727,40 @@ let test_mutiple_inline_ifs () = }; ] +let test_precedence7 () = + _test_instruction "(1 + 1 = '')" + [ + Tree.Ast.Expression + (Tree.Ast.BinaryOp + ( _position, + Eq, + Tree.Ast.BinaryOp + ( _position, + Plus, + Tree.Ast.Integer (_position, "1"), + Tree.Ast.Integer (_position, "1") ), + Tree.Ast.Literal (_position, "") )); + ] + +let test_precedence8 () = + _test_instruction "(0 = 1 or 0 = 1)" + [ + Tree.Ast.Expression + (Tree.Ast.BinaryOp + ( _position, + Or, + Tree.Ast.BinaryOp + ( _position, + Eq, + Tree.Ast.Integer (_position, "0"), + Tree.Ast.Integer (_position, "1") ), + Tree.Ast.BinaryOp + ( _position, + Eq, + Tree.Ast.Integer (_position, "0"), + Tree.Ast.Integer (_position, "1") ) )); + ] + let syntax = ( "Syntax", [ @@ -783,6 +823,8 @@ let syntax = 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; + Alcotest.test_case "Precedence7" `Quick test_precedence7; + Alcotest.test_case "Precedence8" `Quick test_precedence8; ] ) let () = Alcotest.run "qsp_parser" [ syntax ] |