Skip to content

Commit ea793a1

Browse files
committed
Test of documentation extraction for subprograms.
1 parent 6bb7cfc commit ea793a1

File tree

3 files changed

+799
-0
lines changed

3 files changed

+799
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ check_extractor:
1919
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json tasks.ads | diff -u --strip-trailing-cr tasks.out -)
2020
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.ads | diff -u --strip-trailing-cr protecteds.ads.out -)
2121
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.adb | diff -u --strip-trailing-cr protecteds.adb.out -)
22+
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json subprograms_gnat.ads | diff -u --strip-trailing-cr subprograms_gnat.ads.out -)
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
-- This is description of the package at the top of the compilation unit.
2+
--
3+
-- This package provides test cases of documented subprograms using GNAT
4+
-- style.
5+
with Interfaces;
6+
7+
package Subprograms_GNAT is
8+
9+
pragma Preelaborate;
10+
11+
-- This is description of the package at the top of the specification.
12+
13+
type Abstract_Type is abstract tagged limited null record;
14+
-- Abstract tagged type to test abstract subprograms.
15+
16+
----------------
17+
-- Procedures --
18+
----------------
19+
20+
-- Tests of procedures declarations. It extensively test processing of the
21+
-- parameters specifications in different combinations. It allows to
22+
-- minimize number of tests for parameters of the functions, because the
23+
-- same code is used to process parameters of both procedures and
24+
-- functions. Some tests cover use of aspects: documentation between the
25+
-- procedure specification and aspects. Null and abstract procedures are
26+
-- not present in this section, see section for advanced features at the
27+
-- end of this specification.
28+
29+
procedure Test_Procedure_Inline
30+
(X : Interfaces.Integer_64; -- Value of X
31+
Y : Interfaces.IEEE_Float_64;
32+
-- Value of Y
33+
Z : Integer); -- Value of Z
34+
-- This is description of the procedure with "inline" parameter's
35+
-- description.
36+
--
37+
-- @exception Constraint_Error Raised on some error condition.
38+
39+
procedure Test_Procedure_Inline_Aspects
40+
(X : Interfaces.Integer_64; -- Value of X
41+
Y : Interfaces.IEEE_Float_64;
42+
-- Value of Y
43+
Z : Integer) -- Value of Z
44+
with Convention => Ada;
45+
-- This is description of the procedure with "inline" parameter's
46+
-- description and aspects.
47+
-- @exception Constraint_Error Raised on some error condition.
48+
49+
procedure Test_Procedure_Inline_Before_With_Aspects
50+
(X : Interfaces.Integer_64; -- Value of X
51+
Y : Interfaces.IEEE_Float_64;
52+
-- Value of Y
53+
Z : Integer) -- Value of Z
54+
-- This is description of the procedure with "inline" parameter's
55+
-- description and aspects.
56+
-- @exception Constraint_Error Raised on some error condition.
57+
with Convention => Ada;
58+
59+
procedure Test_Procedure_Inline_Before_Aspects
60+
(X : Interfaces.Integer_64; -- Value of X
61+
Y : Interfaces.IEEE_Float_64;
62+
-- Value of Y
63+
Z : Integer) with -- Value of Z
64+
-- This is description of the procedure with "inline" parameter's
65+
-- description and aspects.
66+
-- @exception Constraint_Error Raised on some error condition.
67+
Convention => Ada;
68+
69+
procedure Test_Procedure
70+
(A : String;
71+
B : Character);
72+
-- This is description of the procedure with description of the
73+
-- parameters in comment block.
74+
-- @param A Value of A
75+
-- @param B Value of B
76+
77+
procedure Test_Procedure_Multiple_Parameters
78+
(A, B, C : String; -- Values of strings
79+
D : Character);
80+
-- This is description of the procedure with description of the
81+
-- parameters in comment block.
82+
-- @param A Value of A
83+
-- @param D Value of D
84+
85+
procedure Test_Procedure_Grouped_Parameters
86+
(A : String;
87+
B : String; -- Value of B
88+
C : String;
89+
-- Values of strings
90+
91+
D : Character);
92+
-- This is description of the procedure with description of the
93+
-- parameters in comment block.
94+
-- @param A Value of A
95+
-- @param D Value of D
96+
97+
procedure Test_Procedure_Multiline_Parameters
98+
(A : String; -- Value of A
99+
-- as well as more information about A.
100+
B : String; -- Value of B
101+
C : String;
102+
-- Values of C
103+
-- as well as more information about C.
104+
D : Character);
105+
-- This is description of the procedure with description of the
106+
-- parameters in comment block.
107+
-- @param A And even more about A.
108+
-- @param D Value of D
109+
110+
procedure Test_Single_Line; -- This is single line comment for subprogram
111+
112+
procedure Test (X : Integer); -- Parameter X
113+
-- Procedure with parameter.
114+
115+
---------------
116+
-- Functions --
117+
---------------
118+
119+
-- These tests is mostly oriented to cover functions specific features,
120+
-- like return values. Some tests cover use of aspects. Expression and
121+
-- abstract functions are not present in this section, see section for
122+
-- advanced features at the end of this specification.
123+
124+
function Test (X : Integer; Y : Integer) return Integer;
125+
-- Function with two parameters
126+
--
127+
-- @param X Value of X
128+
-- @param Y Value of Y
129+
-- @return Return value
130+
131+
function Test_2 (X : Integer; Y : Integer)
132+
return -- Multiline inlined description
133+
Integer; -- of the return value
134+
-- Function with two parameters
135+
--
136+
-- @param X Value of X
137+
-- @param Y Value of Y
138+
139+
function Test_Aspects_1 return Integer with Inline;
140+
-- Parameterless single line function declaration.
141+
142+
function Test_Aspects_2 return Integer
143+
-- Parameterless single line function declaration.
144+
with Inline;
145+
146+
function Test_Aspects_3 return Integer with
147+
-- Parameterless single line function declaration.
148+
Convention => Ada;
149+
150+
function Test_Aspects_4
151+
return Integer with -- Retun value is always positive
152+
-- Parameterless single line function declaration.
153+
Convention => Ada;
154+
155+
--------------------
156+
-- Advanced cases --
157+
--------------------
158+
159+
procedure Test_Null is null;
160+
-- Parameterless null subprogram.
161+
162+
procedure Test_Abstract (Self : Abstract_Type) is abstract;
163+
-- Abstract procedure.
164+
165+
function Test_Abstract (Self : Abstract_Type) return Boolean is abstract;
166+
-- Abstract function.
167+
168+
function Test_Expression_1 return Integer is (0);
169+
-- Expression function.
170+
171+
function Test_Expression_2
172+
return Integer
173+
-- Multiline expression function, documentation before expression.
174+
is (0);
175+
176+
function Test_Expression_3
177+
return Integer
178+
-- Multiline expression function, documentation before expression, aspects
179+
-- present.
180+
is (0)
181+
with Inline;
182+
183+
function Test_Expression_4
184+
return Integer
185+
is (0)
186+
-- Multiline expression function, documentation after expression, aspects
187+
-- present.
188+
with Inline;
189+
190+
procedure Test_Procedure_With_Pragma;
191+
pragma Inline (Test_Procedure_With_Pragma);
192+
-- Documentation of the procedure with applied pragma.
193+
194+
type Access_Procedure_1 is access procedure;
195+
-- Access to parameterless procedure.
196+
197+
type Access_Procedure_2 is access procedure (X : Integer); -- Value of X
198+
-- Access to procedure.
199+
200+
type Access_Procedure_3 is access procedure (X, Y : Integer);
201+
-- Access to procedure with two parameters.
202+
--
203+
-- @param X Value of X
204+
-- @param Y Value of Y
205+
206+
type Access_Function_1 is
207+
access function return Integer; -- Return value
208+
-- Access to parameterless function.
209+
210+
type Access_Function_2 is
211+
access function (X : Float) return Integer;
212+
-- Access to function
213+
--
214+
-- @param X Value of X
215+
-- @return Return value
216+
217+
private
218+
219+
-- This is description of the package at the beginning of the private
220+
-- part of the specification.
221+
222+
end Subprograms_GNAT;

0 commit comments

Comments
 (0)