Debian Codegraph @

test-suite/success/PartialImport.v

raw
1 Module M.
2
3 Definition a := 0.
4 Definition b := 1.
5
6 Module N.
7
8 Notation c := (a + b).
9
10 End N.
11
12 Inductive even : nat -> Prop :=
13 | even_0 : even 0
14 | even_S n : odd n -> even (S n)
15 with odd : nat -> Set :=
16 odd_S n : even n -> odd (S n).
17
18 End M.
19
20 Module Simple.
21
22 Import M(a).
23
24 Check a.
25 Fail Check b.
26 Fail Check N.c.
27
28 (* todo output test: this prints a+M.b since the notation isn't imported *)
29 Check M.N.c.
30
31 Fail Import M(c).
32 Fail Import M(M.b).
33
34 Import M(N.c).
35 Check N.c.
36 (* interestingly prints N.c (also does with unfiltered Import M) *)
37
38 Import M(even(..)).
39 Check even. Check even_0. Check even_S.
40 Check even_sind. Check even_ind.
41 Fail Check even_rect. (* doesn't exist *)
42 Fail Check odd. Check M.odd.
43 Fail Check odd_S. Fail Check odd_sind.
44
45 End Simple.
46
47 Module WithExport.
48
49 Module X.
50 Export M(a, N.c).
51 End X.
52
53 Import X.
54 Check a.
55 Check N.c. (* also prints N.c *)
56 Fail Check b.
57
58 End WithExport.
59
60 Module IgnoreLocals.
61 Module X.
62 Local Definition x := 0.
63 Definition y := 1.
64 End X.
65
66 Set Warnings "+not-importable".
67 Fail Import X(x,y).
68 Set Warnings "-not-importable".
69 Import X(x,y).
70 Check y.
71 Fail Check x.
72 Check X.x.
73 End IgnoreLocals.
74
75 Module FancyFunctor.
76 (* A fancy behaviour with functors, not sure if we want to keep it
77 but at least the test will ensure changes are deliberate. *)
78
79 Module Type T.
80 Parameter x : nat.
81 End T.
82 Module X.
83 Definition x := 0.
84 Definition y := 1.
85 End X.
86
87 Module Y.
88 Local Definition x := 2.
89 End Y.
90
91 Module F(A:T).
92 Export A(x).
93 End F.
94 Module Import M := F X.
95 Check x.
96 Fail Check y.
97
98 Module N := F Y.
99 Set Warnings "+not-importable".
100 Fail Import N.
101 Set Warnings "-not-importable".
102 Import N.
103 Check eq_refl : x = 0.
104
105 End FancyFunctor.
106
107 Require Import Sumbool(sumbool_of_bool).
108 Check sumbool_of_bool.
109 Check Sumbool.bool_eq_rec.
110
111 Fail Require Sumbool(sumbool_of_bool).
112 Fail Require Import Sumbool(not_a_real_definition).
113 Fail Require Import(notations) Sumbool(sumbool_of_bool).