Skip to content

Commit c11dfa3

Browse files
committed
add tests for ocaml syntax highlighting
1 parent f1d821c commit c11dfa3

13 files changed

+89
-0
lines changed

syntax-testcases/exception_alias.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(* ok *)
2+
exception E = F

syntax-testcases/functor1.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(* ok *)
2+
module M : sig
3+
module type F
4+
= functor () (X : Ord) -> sig end
5+
module F
6+
: functor () (X : Ord) -> sig end
7+
end
8+
= struct
9+
module type F
10+
= functor () (X : Ord) -> sig end
11+
module F
12+
: functor () (X : Ord) -> sig end
13+
= functor () (X : Ord) -> struct end
14+
end
15+
16+
module type F
17+
= functor () (X : Ord) -> sig end
18+
module F
19+
: functor () (X : Ord) -> sig end
20+
= functor () (X : Ord) -> struct end

syntax-testcases/functor2.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(* https://github.com/ocaml/vim-ocaml/issues/3 *)
2+
3+
module Make (M : sig end) = struct module type S = sig end end
4+
module Test : Make(Make(Int)).S = struct end
5+
(* ----------------^ the inner modules are linted as constructors *)

syntax-testcases/functor3.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Make : functor(X: Ord) -> sig
2+
module Bar : module type of Make(X)
3+
4+
val x : int
5+
val y : int
6+
end

syntax-testcases/functor_param.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module M : sig
2+
module F () (X : Ord) : sig end
3+
end
4+
= struct
5+
module F () (X : Ord) : sig end = struct end
6+
end
7+
8+
module F () (X : Ord) : sig end = struct end

syntax-testcases/module_paren1.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module M0 : sig end = struct let x = 0 end
2+
(* => linting of struct is correct *)
3+
4+
module M1 : sig end = (struct let x = 0 end : sig end)
5+
(* => linting of struct is correct
6+
(but linting of last sig is buggy because of the type linter of PR#76) *)
7+
8+
module M2 = (struct let x = 0 end : sig end)
9+
(* => ^^^^^^^^^^^^^^^^^^^^
10+
the whole struct is linted with a wrong, uniform style
11+
(but linting of last sig is correct) *)

syntax-testcases/module_paren2.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(* https://github.com/ocaml/vim-ocaml/issues/6 *)
2+
3+
module IM = Stdlib.Map.Make(Int)
4+
(* ^^^^^^^^^^^^^^^^^^^^
5+
shown as a module/functor, with a uniform style *)
6+
7+
module IM : sig end = Stdlib.Map.Make(Int)
8+
(* ^^^^^^^^^^^^^^^^^^^^
9+
shown as as an expression (a datatype constructor `Make`
10+
prefixed with a module path, and a constructor `Int`) *)

syntax-testcases/module_type.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(* https://github.com/ocaml/vim-ocaml/issues/84 *)
2+
(* Foo is highlighted incorrectly *)
3+
type x = (module Foo)

syntax-testcases/module_type_of.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(* approximately ok:
2+
* - "module type of" linted as ocamlKeyword
3+
* - "F" linted as ocamlModule
4+
* - "(X)" linted meaninglessly but by chance it doesn’t look SO bad
5+
*)
6+
module N : module type of F(X)
7+
8+
module M : sig
9+
module N : module type of X
10+
module N : module type of F(X)
11+
val x : int
12+
end

syntax-testcases/module_underscore.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(* ok *)
2+
module _ = struct
3+
let () = ()
4+
end

0 commit comments

Comments
 (0)