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.ml6
2 files changed, 21 insertions, 7 deletions
diff --git a/test/syntax.ml b/test/syntax.ml
index ce3e89e..64c5004 100644
--- a/test/syntax.ml
+++ b/test/syntax.ml
@@ -33,10 +33,10 @@ let parse : string -> (S.pos location, Qsp_syntax.Report.t) result =
(module Parser)
Qparser.Analyzer.Location lexing context
|> Result.map (fun v ->
- (* Uncatched excteptions here, but we are in the tests…
+ (* Uncatched excteptions here, but we are in the tests…
If it’s fail here I have an error in the code. *)
- Array.get v.Qparser.Analyzer.content 0
- |> Check.get location_id |> Option.get)
+ Array.get v.Qparser.Analyzer.content 0
+ |> Check.get location_id |> Option.get)
let location : S.pos location Alcotest.testable =
let equal = equal_location (fun _ _ -> true) in
@@ -895,8 +895,21 @@ let test_stattxt () =
{ Tree.Ast.pos = _position; name = "$STATTXT"; index = None } );
]
+let test_function_no_args () =
+ let expected =
+ [
+ Tree.Ast.Declaration
+ ( _position,
+ { Tree.Ast.pos = _position; name = "VALUE"; index = None },
+ T.Eq',
+ Tree.Ast.Function (_position, T.Msecscount, []) );
+ ]
+ in
+ _test_instruction "value = msecscount" expected;
+ _test_instruction "value = msecscount()" expected
+
let test_syntax =
- ( "Syntax",
+ ( __FILE__,
[
Alcotest.test_case "Location" `Quick test_empty_location;
Alcotest.test_case "Location" `Quick test_location_without_space;
@@ -957,6 +970,7 @@ let test_syntax =
Alcotest.test_case "Precedence7" `Quick test_precedence7;
Alcotest.test_case "Precedence8" `Quick test_precedence8;
Alcotest.test_case "stattxt" `Quick test_stattxt;
+ Alcotest.test_case "stattxt" `Quick test_function_no_args;
] )
let test_comments =
diff --git a/test/syntax_error.ml b/test/syntax_error.ml
index 9d51cf3..209d3e2 100644
--- a/test/syntax_error.ml
+++ b/test/syntax_error.ml
@@ -23,7 +23,7 @@ let _test_instruction :
let _location = Printf.sprintf {|# Location
%s
------- |} literal in
- let actual = get_report @@ Syntax.parse _location and msg = literal in
+ let actual = get_report @@ Syntax.parse _location and msg = _location in
let () = Alcotest.(check' report ~msg ~expected ~actual) in
match k with None -> () | Some f -> f actual
@@ -291,7 +291,7 @@ let missing_operator () =
{ level = Error; loc = _position; message = "Missing operator before text" }
let test =
- ( "Syntax Errors",
+ ( __FILE__,
[
Alcotest.test_case "else:" `Quick else_column;
Alcotest.test_case "elseif" `Quick elseif_no_column;
@@ -305,7 +305,7 @@ let test =
Alcotest.test_case "Unknown function" `Quick unknow_function;
Alcotest.test_case "Inline elif" `Quick inline_elif;
Alcotest.test_case "Unclosed block" `Quick unclosed_block;
- Alcotest.test_case "Unclosed block" `Quick comment_as_operator;
+ Alcotest.test_case "Comment as separator" `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;