Skip to content

Commit ac09c84

Browse files
committed
fix test suite
1 parent 93bd0fe commit ac09c84

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

language-server/tests/common.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ let rec parse : type a. int -> int -> Document.sentence list -> Document.parsing
7474
| O, [], [] -> Ok ()
7575
| P spec, s :: l, errors ->
7676
parse (m+1) n l errors spec >>= (fun a -> Ok(ss_of_s s,a))
77-
| E spec, sentences, error :: l ->
77+
| E _, [], error :: _ ->
78+
Error ("erroneous sentence not part of the document. Corresponding error is " ^ Pp.string_of_ppcmds @@ snd error.Document.msg)
79+
| E spec, _ :: sentences, error :: l ->
7880
parse m (n+1) sentences l spec >>= (fun a -> Ok(error,a))
79-
| O, (_ :: _ as l), _ -> Error ("more sentences than expected, extra " ^ Int.to_string (List.length l))
81+
| O, (s :: _ as l), _ -> Error ("more sentences than expected, extra " ^ Int.to_string (List.length l) ^ ". Extra sentence is " ^ Document.Internal.string_of_sentence s)
8082
| O, _, (_ :: _ as l) -> Error ("more errors than expected, extra " ^ Int.to_string (List.length l))
8183
| P _, [], errors ->
8284
let errors = String.concat ~sep:"\n" @@ List.map ~f:(fun err -> Pp.string_of_ppcmds @@ snd err.Document.msg) errors in

language-server/tests/dm_tests.ml

+9-3
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,31 @@ let%test_unit "parse.insert" =
5555
check_no_diag st
5656

5757
let%test_unit "parse.squash" =
58+
(* 1 2 3 4 5 6 7*)
59+
(*01234567890123456789012345678901234567890123456789012345678901234567890*)
5860
let st, init_events = em_init_test_doc ~text:"Definition x := true. Definition y := false. Definition z := 0." in
5961
let st = edit_text st ~start:20 ~stop:21 ~text:"" in
6062
let doc = DocumentManager.Internal.document st in
6163
let sentences = Document.sentences doc in
6264
let start_positions = Stdlib.List.map (fun (s : Document.sentence) -> s.Document.start) sentences in
6365
let stop_positions = Stdlib.List.map (fun (s : Document.sentence) -> s.Document.stop) sentences in
64-
[%test_eq: int list] start_positions [ 44 ];
65-
[%test_eq: int list] stop_positions [ 62 ];
66+
[%test_eq: int list] start_positions [ 0; 44 ];
67+
[%test_eq: int list] stop_positions [ 43; 62 ];
6668
[%test_eq: int] (List.length (Document.parse_errors doc)) 1
6769

6870
let%test_unit "parse.error_recovery" =
71+
(* 1 2 3 4 5 6 7*)
72+
(*01234567890123456789012345678901234567890123456789012345678901234567890*)
6973
let st, init_events = em_init_test_doc ~text:"## . Definition x := true. !! . Definition y := false." in
7074
let doc = DocumentManager.Internal.document st in
7175
let sentences = Document.sentences doc in
7276
let start_positions = Stdlib.List.map (fun (s : Document.sentence) -> s.Document.start) sentences in
73-
[%test_eq: int list] start_positions [ 5; 32 ];
77+
[%test_eq: int list] start_positions [ 0; 5; 26; 32 ];
7478
[%test_eq: int] (List.length (Document.parse_errors doc)) 2
7579

7680
let%test_unit "parse.extensions" =
81+
(* 1 2 3 4 5 6 7*)
82+
(*01234567890123456789012345678901234567890123456789012345678901234567890*)
7783
let st, init_events = em_init_test_doc ~text:"Notation \"## x\" := x (at level 0). Definition f (x : nat) := ##xx." in
7884
let sentences = Document.sentences @@ DocumentManager.Internal.document st in
7985
let start_positions = Stdlib.List.map (fun (s : Document.sentence) -> s.Document.start) sentences in

0 commit comments

Comments
 (0)