Skip to content

Commit 4d99e01

Browse files
committed
Add a cram test for internal tags warnings
1 parent 6192cf0 commit 4d99e01

File tree

6 files changed

+81
-8
lines changed

6 files changed

+81
-8
lines changed

test/model/dune

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
(library
2-
(name odoc_model_test)
3-
(inline_tests)
4-
(enabled_if
5-
(>= %{ocaml_version} 4.04.1))
6-
(preprocess
7-
(pps ppx_expect))
8-
(libraries sexplib0 odoc_model type_desc_to_yojson))
1+
; Use the 'compile' helper program defined in xref2 tests
2+
3+
(env
4+
(_
5+
(binaries
6+
(../odoc_print/odoc_print.exe as odoc_print)
7+
(../xref2/compile.exe as compile))))
8+
9+
(cram
10+
(deps %{bin:odoc} %{bin:odoc_print} %{bin:compile}))

test/model/internal_tags.t/bad.mli

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(** Status tags in the top-comment.
2+
3+
@inline *)
4+
5+
(** Canonical on an [include].
6+
7+
@canonical X.Y *)
8+
include sig end
9+
10+
(** Canonical on a value.
11+
12+
@canonical X.x *)
13+
val x : int
14+
15+
(** Canonical in a floating comment.
16+
17+
@canonical X.Y *)
18+
19+
(** Status tags on a value.
20+
21+
@inline *)
22+
val x : int

test/model/internal_tags.t/good.mli

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(** Canonical tag in the top-comment
2+
3+
@canonical A.B *)
4+
5+
module type T = sig type t end
6+
7+
include T
8+
(** Status tags on an [include]. Only the first one will be taken into account.
9+
10+
@open
11+
@closed
12+
@inline *)
13+
14+
type u
15+
(** Canonical on a type.
16+
17+
@canonical A.u *)
18+
19+
module M : sig end
20+
(** Canonical on a module.
21+
22+
@canonical A.B *)

test/model/internal_tags.t/run.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Test handling of internal tags.
2+
We expect no warning for "good.mli". The code already ensures that either tags
3+
are handled of a warning is emitted.
4+
5+
$ compile good.mli
6+
7+
We expect warnings to be emitted for each bad tags:
8+
9+
$ compile bad.mli
10+
File "bad.mli", line 3, characters 4-11:
11+
Unexpected tag '@inline' at this location.
12+
File "bad.mli", line 7, characters 4-19:
13+
Unexpected tag '@canonical' at this location.
14+
File "bad.mli", line 12, characters 4-19:
15+
Unexpected tag '@canonical' at this location.
16+
File "bad.mli", line 17, characters 4-19:
17+
Unexpected tag '@canonical' at this location.
18+
File "bad.mli", line 21, characters 4-11:
19+
Unexpected tag '@inline' at this location.

test/model/semantics/dune

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(library
2+
(name odoc_model_semantics_test)
3+
(inline_tests)
4+
(enabled_if
5+
(>= %{ocaml_version} 4.04.1))
6+
(preprocess
7+
(pps ppx_expect))
8+
(libraries sexplib0 odoc_model type_desc_to_yojson))
File renamed without changes.

0 commit comments

Comments
 (0)