aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/syntax.ml22
-rw-r--r--test/syntax_error.ml21
2 files changed, 21 insertions, 22 deletions
diff --git a/test/syntax.ml b/test/syntax.ml
index 3b7c2f9..47f1a25 100644
--- a/test/syntax.ml
+++ b/test/syntax.ml
@@ -444,27 +444,6 @@ end |}
};
]
-let test_if2 () =
- let index = Some Ast.(Integer (_position, "0")) in
- let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
- and expr1 = Ast.(Literal (_position, [ T.Text "blockA" ]))
- and expr2 =
- Ast.(Expression (Literal (_position, [ T.Text "You are in block A" ])))
- in
- _test_instruction {| if $ARGS[0] = 'blockA':
- 'You are in block A'
-end if|}
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, BinaryOp (_position, Eq, args, expr1), [ expr2 ]);
- elifs = [];
- else_ = [];
- };
- ]
-
let test_if_chained () =
let value_0 = Ast.Integer (_position, "0") in
_test_instruction {| if 0:
@@ -937,7 +916,6 @@ let test =
Alcotest.test_case "Comment6" `Quick test_comment6;
Alcotest.test_case "Multiline Comment" `Quick test_long_comment;
Alcotest.test_case "If" `Quick test_if;
- Alcotest.test_case "If - end if" `Quick test_if2;
Alcotest.test_case "If_chained" `Quick test_if_chained;
Alcotest.test_case "If_equality" `Quick test_if_equality;
Alcotest.test_case "If inline" `Quick test_if_inline;
diff --git a/test/syntax_error.ml b/test/syntax_error.ml
index 04b91ad..490ec96 100644
--- a/test/syntax_error.ml
+++ b/test/syntax_error.ml
@@ -206,6 +206,26 @@ let location_change () =
check' ~msg:"The location name is not valid" string ~actual
~expected:"Location"))
+let misplaced_if () =
+ _test_instruction {|
+if $ARGS[0] = 'arg':
+ 0
+end if|}
+ {
+ level = Error;
+ loc = _position;
+ message = "Unexpected instruction after `IF` `END` block.";
+ };
+ _test_instruction {|
+act 'arg':
+ 0
+end if|}
+ {
+ level = Error;
+ loc = _position;
+ message = "Unexpected instruction after `ACT` `END` block.";
+ }
+
(* The location name *)
let test =
@@ -225,4 +245,5 @@ let test =
Alcotest.test_case "Unclosed block" `Quick comment_as_operator;
Alcotest.test_case "Missing comparable" `Quick missing_comparable;
Alcotest.test_case "Location change" `Quick location_change;
+ Alcotest.test_case "Misplaced if" `Quick misplaced_if;
] )