Skip to content

Commit 2a1b4a1

Browse files
committed
add tests for ocaml syntax highlighting
1 parent 052e9b9 commit 2a1b4a1

14 files changed

+84
-0
lines changed

syntax-testcases/exception_alias.ml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(* ok *)
2+
exception E = F
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module M1 : sig end = (struct let x = 0 end : sig end)
2+
(* => last signature: `sig` is linted as a type constructor, end `end` as an error *)

syntax-testcases/functor1.ml

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

syntax-testcases/functor2.ml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Make (M : sig end) = struct module type S = sig end end
2+
module Test : Make(Make(Int)).S = struct end
3+
(* ----------------^ the inner modules are linted as constructors *)

syntax-testcases/functor3.mli

+6
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

+8
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

+11
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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module IM = Stdlib.Map.Make(Int)
2+
(* ^^^^^^^^^^^^^^^^^^^^
3+
shown as a module/functor, with a uniform style *)
4+
5+
module IM : sig end = Stdlib.Map.Make(Int)
6+
(* ^^^^^^^^^^^^^^^^^^^^
7+
shown as as an expression (a datatype constructor `Make`
8+
prefixed with a module path, and a constructor `Int`) *)

syntax-testcases/module_type.ml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(* Foo is highlighted incorrectly *)
2+
type x = (module Foo)

syntax-testcases/module_type_of.mli

+12
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

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(* ok *)
2+
module _ = struct
3+
let () = ()
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module F : Bar = Foo
2+
3+
module Test : Make(Int).S = struct end
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(* foo is highlighted incorrectly on every line *)
2+
val bar : [>foo]
3+
let decode x = (Dns.Packet.decode x : (_, Dns.Packet.err) result :> (_, [> foo]) result)
4+
type t = [Dns.Packet.foo | Dns.Packet.bar]
File renamed without changes.

0 commit comments

Comments
 (0)