summaryrefslogtreecommitdiff
path: root/testsuite/tests/shapes/open_struct.ml
blob: fb3199ea9a2c94cd80acd2809bc558bbd8acd9df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(* TEST
 flags = "-dshape";
 expect;
*)

(* Everything that couldn't go anywhere else. *)

open struct
  module M = struct
    type t = A
  end
end
[%%expect{|
{
 }
module M : sig type t = A end
|}]

include M
[%%expect{|
{
 "t"[type] -> <.0>;
 }
type t = M.t = A
|}]

module N = M
[%%expect{|
{
 "N"[module] -> {<.2>
                 "t"[type] -> <.0>;
                 };
 }
module N = M
|}]

(* Not open structs, but the code handling the following is currently very
   similar to the one for open struct (i.e. calls [Env.enter_signature]), and
   so we are likely to encounter the same bugs, if any. *)

include struct
  module M' = struct
    type t = A
  end
end
[%%expect{|
{
 "M'"[module] -> {<.6>
                  "t"[type] -> <.4>;
                  };
 }
module M' : sig type t = A end
|}]

module N' = M'
[%%expect{|
{
 "N'"[module] -> {<.6>
                  "t"[type] -> <.4>;
                  };
 }
module N' = M'
|}]

module Test = struct
  module M = struct
    type t = A
  end
end
[%%expect{|
{
 "Test"[module] -> {<.11>
                    "M"[module] -> {<.10>
                                    "t"[type] -> <.8>;
                                    };
                    };
 }
module Test : sig module M : sig type t = A end end
|}]

include Test
[%%expect{|
{
 "M"[module] -> {<.10>
                 "t"[type] -> <.8>;
                 };
 }
module M = Test.M
|}]

module N = M
[%%expect{|
{
 "N"[module] -> {<.10>
                 "t"[type] -> <.8>;
                 };
 }
module N = M
|}]