Skip to content

Commit

Permalink
add tests for ocaml syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Feb 8, 2023
1 parent 052e9b9 commit dbaebec
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions syntax-testcases/exception_alias.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(* ok *)
exception E = F
20 changes: 20 additions & 0 deletions syntax-testcases/functor1.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(* ok *)
module M : sig
module type F
= functor () (X : Ord) -> sig end
module F
: functor () (X : Ord) -> sig end
end
= struct
module type F
= functor () (X : Ord) -> sig end
module F
: functor () (X : Ord) -> sig end
= functor () (X : Ord) -> struct end
end

module type F
= functor () (X : Ord) -> sig end
module F
: functor () (X : Ord) -> sig end
= functor () (X : Ord) -> struct end
5 changes: 5 additions & 0 deletions syntax-testcases/functor2.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(* https://github.com/ocaml/vim-ocaml/issues/3 *)

module Make (M : sig end) = struct module type S = sig end end
module Test : Make(Make(Int)).S = struct end
(* ----------------^ the inner modules are linted as constructors *)
6 changes: 6 additions & 0 deletions syntax-testcases/functor3.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Make : functor(X: Ord) -> sig
module Bar : module type of Make(X)

val x : int
val y : int
end
8 changes: 8 additions & 0 deletions syntax-testcases/functor_param.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module M : sig
module F () (X : Ord) : sig end
end
= struct
module F () (X : Ord) : sig end = struct end
end

module F () (X : Ord) : sig end = struct end
11 changes: 11 additions & 0 deletions syntax-testcases/module_paren1.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module M0 : sig end = struct let x = 0 end
(* => linting of struct is correct *)

module M1 : sig end = (struct let x = 0 end : sig end)
(* => linting of struct is correct
(but linting of last sig is buggy because of the type linter of PR#76) *)

module M2 = (struct let x = 0 end : sig end)
(* => ^^^^^^^^^^^^^^^^^^^^
the whole struct is linted with a wrong, uniform style
(but linting of last sig is correct) *)
10 changes: 10 additions & 0 deletions syntax-testcases/module_paren2.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(* https://github.com/ocaml/vim-ocaml/issues/6 *)

module IM = Stdlib.Map.Make(Int)
(* ^^^^^^^^^^^^^^^^^^^^
shown as a module/functor, with a uniform style *)

module IM : sig end = Stdlib.Map.Make(Int)
(* ^^^^^^^^^^^^^^^^^^^^
shown as as an expression (a datatype constructor `Make`
prefixed with a module path, and a constructor `Int`) *)
3 changes: 3 additions & 0 deletions syntax-testcases/module_type.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(* https://github.com/ocaml/vim-ocaml/issues/84 *)
(* Foo is highlighted incorrectly *)
type x = (module Foo)
12 changes: 12 additions & 0 deletions syntax-testcases/module_type_of.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(* approximately ok:
* - "module type of" linted as ocamlKeyword
* - "F" linted as ocamlModule
* - "(X)" linted meaninglessly but by chance it doesn’t look SO bad
*)
module N : module type of F(X)

module M : sig
module N : module type of X
module N : module type of F(X)
val x : int
end
4 changes: 4 additions & 0 deletions syntax-testcases/module_underscore.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(* ok *)
module _ = struct
let () = ()
end
3 changes: 3 additions & 0 deletions syntax-testcases/module_with_signature.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module F : Bar = Foo

module Test : Make(Int).S = struct end
5 changes: 5 additions & 0 deletions syntax-testcases/poly_variant_in_type.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(* https://github.com/ocaml/vim-ocaml/issues/88 *)
(* foo is highlighted incorrectly on every line *)
val bar : [>foo]
let decode x = (Dns.Packet.decode x : (_, Dns.Packet.err) result :> (_, [> foo]) result)
type t = [Dns.Packet.foo | Dns.Packet.bar]
File renamed without changes.

0 comments on commit dbaebec

Please sign in to comment.