Skip to content

Commit 1d7f92d

Browse files
committed
Cleanup canonical tests
1 parent 9492dce commit 1d7f92d

File tree

8 files changed

+75
-92
lines changed

8 files changed

+75
-92
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Test that @canonical tags work on compilation units when it is placed in the
2+
top-comment.
3+
4+
The module Test_x is expected to be referenced as Test.X.
5+
6+
$ compile test_x.mli test_y.ml test.ml
7+
8+
Test_x and Test_y have a 'canonical' field:
9+
10+
$ odoc_print test_x.odocl | jq -c ".canonical"
11+
{"Some":{"`Dot":[{"`Root":"Test"},"X"]}}
12+
$ odoc_print test_y.odocl | jq -c ".canonical"
13+
{"Some":{"`Dot":[{"`Root":"Test"},"Y"]}}
14+
15+
Test_x is defined as a .mli file and Test_y as a .ml file in order to test the
16+
loader code handling canonical tags.
17+
18+
Submodules *_out have the canonical tag in the declarations and submodules *_in
19+
have it in the top-comment.
20+
21+
Every references should be marked as canonical:
22+
23+
$ odoc_print test.odocl | jq -c ".content.Module.items | .[] | .Module[1].type_.Alias[0] | select(.)"
24+
{"`Resolved":{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"X"]}}]}}]}}
25+
{"`Resolved":{"`Canonical":[{"`Module":[{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"X"]}}]}}]},"Out"]},{"`Resolved":{"`Alias":[{"`Module":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},"Out"]},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"X_out"]}}]}}]}}
26+
{"`Resolved":{"`Canonical":[{"`Module":[{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"X"]}}]}}]},"In"]},{"`Resolved":{"`Alias":[{"`Module":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_x"]}},"In"]},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"X_in"]}}]}}]}}
27+
{"`Resolved":{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"Y"]}}]}}]}}
28+
{"`Resolved":{"`Canonical":[{"`Module":[{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"Y"]}}]}}]},"Out"]},{"`Resolved":{"`Alias":[{"`Module":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},"Out"]},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"Y_out"]}}]}}]}}
29+
{"`Resolved":{"`Canonical":[{"`Module":[{"`Canonical":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Resolved":{"`Alias":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"Y"]}}]}}]},"In"]},{"`Resolved":{"`Alias":[{"`Module":[{"`Identifier":{"`Root":[{"`RootPage":"test"},"Test_y"]}},"In"]},{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"Y_in"]}}]}}]}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(** Main module of this test. See [run.t] *)
2+
3+
module X = Test_x
4+
module X_out = Test_x.Out
5+
module X_in = Test_x.In
6+
module Y = Test_y
7+
module Y_out = Test_y.Out
8+
module Y_in = Test_y.In
9+
10+
type t = Test_x.t (* Through hidden path *)
11+
12+
type u = Y.t (* Through canonical path *)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(** We expect this module to be referenced through Test.X.
2+
3+
@canonical Test.X *)
4+
5+
type t
6+
(** @canonical Test.t *)
7+
8+
(** @canonical Test.X_out *)
9+
module Out : sig
10+
type t
11+
end
12+
13+
module In : sig
14+
(** @canonical Test.X_in *)
15+
16+
(** @canonical Test.v *)
17+
type t
18+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(** An other canonical unit test but this time in an .ml file.
2+
3+
@canonical Test.Y *)
4+
5+
type t
6+
7+
(** @canonical Test.Y_out *)
8+
module Out = struct
9+
type t
10+
end
11+
12+
module In = struct
13+
(** @canonical Test.Y_in *)
14+
15+
type t
16+
end

test/xref2/canonical_unit.t/run.t

Lines changed: 0 additions & 29 deletions
This file was deleted.

test/xref2/canonical_unit.t/test.ml

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/xref2/canonical_unit.t/test_w.ml

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/xref2/canonical_unit.t/test_x.mli

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)