annotate gcc/testsuite/ada/acats/tests/ca/ca110051.am @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CA110051.AM
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that entities and operations declared in a package can be used
kono
parents:
diff changeset
28 -- in the private part of a child of a child of the package.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION:
kono
parents:
diff changeset
31 -- Declare a series of library unit packages -- parent, child, and
kono
parents:
diff changeset
32 -- grandchild. The grandchild package will have a private part.
kono
parents:
diff changeset
33 -- From within the private part of the grandchild, make use of
kono
parents:
diff changeset
34 -- components declared in the parent and grandparent packages.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- TEST FILES:
kono
parents:
diff changeset
37 -- The test consists of the following files:
kono
parents:
diff changeset
38 --
kono
parents:
diff changeset
39 -- CA110050.A
kono
parents:
diff changeset
40 -- => CA110051.AM
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- CHANGE HISTORY:
kono
parents:
diff changeset
44 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 --!
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 -- Grandchild Package Message.Text.Encoded
kono
parents:
diff changeset
49 package CA110050_0.CA110050_1.CA110050_2 is
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 type Coded_Message is new Text_Message_Type with private;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 procedure Send (Message : in Coded_Message;
kono
parents:
diff changeset
54 Confirm : out Coded_Message;
kono
parents:
diff changeset
55 Status : out Boolean);
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 function Encode (Message : Text_Message_Type) return Coded_Message;
kono
parents:
diff changeset
58 function Decode (Message : Coded_Message) return Boolean;
kono
parents:
diff changeset
59 function Test_Connection return Boolean;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 private
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Uncoded : Descriptor renames Null_Descriptor_Value; -- Grandparent object.
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 type Coded_Message is new Text_Message_Type with -- Parent type.
kono
parents:
diff changeset
66 record
kono
parents:
diff changeset
67 Key : Descriptor := Uncoded;
kono
parents:
diff changeset
68 Coded_Key : Descriptor := Next_Available_Message;
kono
parents:
diff changeset
69 -- Grandparent type, grandparent function.
kono
parents:
diff changeset
70 Scrambled : Text_Type := Null_Text; -- Parent object.
kono
parents:
diff changeset
71 end record;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Coded_Msg : Coded_Message;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 type Blank_Message is new Message_Type with -- Grandparent type.
kono
parents:
diff changeset
76 record
kono
parents:
diff changeset
77 ID : Descriptor := Next_Available_Message;
kono
parents:
diff changeset
78 -- Grandparent type, grandparent function.
kono
parents:
diff changeset
79 end record;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 Test_Message : Blank_Message;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 Confirm_String : constant String := "OK";
kono
parents:
diff changeset
84 Scrambled_String : constant String := "KO";
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Confirm_Text : Text_Type (Confirm_String'Length) :=
kono
parents:
diff changeset
87 (Max_Length => Confirm_String'Length,
kono
parents:
diff changeset
88 Length => Confirm_String'Length,
kono
parents:
diff changeset
89 Text_Field => Confirm_String);
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Scrambled_Text : Text_Type (Scrambled_String'Length) :=
kono
parents:
diff changeset
92 (Max_Length => Scrambled_String'Length,
kono
parents:
diff changeset
93 Length => Scrambled_String'Length,
kono
parents:
diff changeset
94 Text_Field => Scrambled_String);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 end CA110050_0.CA110050_1.CA110050_2; -- Grandchild Pkg Message.Text.Encoded
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 --=================================================================--
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- Grandchild Package body Message.Text.Encoded
kono
parents:
diff changeset
101 package body CA110050_0.CA110050_1.CA110050_2 is
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Send (Message : in Coded_Message;
kono
parents:
diff changeset
104 Confirm : out Coded_Message;
kono
parents:
diff changeset
105 Status : out Boolean) is
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 Confirmation_Message : Coded_Message :=
kono
parents:
diff changeset
108 (Number => Message.Number,
kono
parents:
diff changeset
109 Text => Confirm_Text,
kono
parents:
diff changeset
110 Key => Message.Number,
kono
parents:
diff changeset
111 Coded_Key => Message.Number,
kono
parents:
diff changeset
112 Scrambled => Scrambled_Text);
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 begin -- Dummy processing unit.
kono
parents:
diff changeset
115 Confirm := Confirmation_Message;
kono
parents:
diff changeset
116 if Confirm.Number /= Null_Message_Descriptor then
kono
parents:
diff changeset
117 Status := True;
kono
parents:
diff changeset
118 else
kono
parents:
diff changeset
119 Status := False;
kono
parents:
diff changeset
120 end if;
kono
parents:
diff changeset
121 end Send;
kono
parents:
diff changeset
122 -------------------------------------------------------------------------
kono
parents:
diff changeset
123 function Encode (Message : Text_Message_Type) return Coded_Message is
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 Coded_Msg.Number := Message.Number;
kono
parents:
diff changeset
126 if Message.Text.Length > 0 then
kono
parents:
diff changeset
127 Coded_Msg.Text := Message.Text; -- Record assignment.
kono
parents:
diff changeset
128 Coded_Msg.Key := Message.Number; -- Same as msg number.
kono
parents:
diff changeset
129 Coded_Msg.Coded_Key := Message.Number; -- Same as msg number.
kono
parents:
diff changeset
130 Coded_Msg.Scrambled := Message.Text; -- Dummy processing.
kono
parents:
diff changeset
131 end if;
kono
parents:
diff changeset
132 return (Coded_Msg);
kono
parents:
diff changeset
133 end Encode;
kono
parents:
diff changeset
134 -------------------------------------------------------------------------
kono
parents:
diff changeset
135 function Decode (Message : Coded_Message) return Boolean is
kono
parents:
diff changeset
136 Decoded : Boolean := False;
kono
parents:
diff changeset
137 begin
kono
parents:
diff changeset
138 if (Message.Text.Length = Confirm_String'Length) and then
kono
parents:
diff changeset
139 (Message.Text.Text_Field = Confirm_String) and then
kono
parents:
diff changeset
140 (Message.Scrambled.Length = Scrambled_String'Length) and then
kono
parents:
diff changeset
141 (Message.Scrambled.Text_Field = Scrambled_String) and then
kono
parents:
diff changeset
142 (Message.Coded_Key = 15)
kono
parents:
diff changeset
143 then
kono
parents:
diff changeset
144 Decoded := True;
kono
parents:
diff changeset
145 end if;
kono
parents:
diff changeset
146 return (Decoded);
kono
parents:
diff changeset
147 end Decode;
kono
parents:
diff changeset
148 -------------------------------------------------------------------------
kono
parents:
diff changeset
149 function Test_Connection return Boolean is
kono
parents:
diff changeset
150 begin
kono
parents:
diff changeset
151 return Test_Message.Id = 10;
kono
parents:
diff changeset
152 end Test_Connection;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 end CA110050_0.CA110050_1.CA110050_2;
kono
parents:
diff changeset
155 -- Grandchild Package body Message.Text.Encoded
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 --=================================================================--
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 with CA110050_0.CA110050_1.CA110050_2;
kono
parents:
diff changeset
160 with Report;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 procedure CA110051 is
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 package Message_Package renames CA110050_0.CA110050_1;
kono
parents:
diff changeset
165 package Code_Package renames CA110050_0.CA110050_1.CA110050_2;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 Message_String : constant String := "One if by land, two if by sea";
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 Message_Text : Message_Package.Text_Type (Message_String'Length) :=
kono
parents:
diff changeset
170 (Max_Length => Message_String'Length,
kono
parents:
diff changeset
171 Length => Message_String'Length,
kono
parents:
diff changeset
172 Text_Field => Message_String);
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 Message : Message_Package.Text_Message_Type :=
kono
parents:
diff changeset
175 (Number => CA110050_0.Next_Available_Message,
kono
parents:
diff changeset
176 Text => Message_Text);
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 Confirmation_Message : Code_Package.Coded_Message;
kono
parents:
diff changeset
179 Verification_OK : Boolean := False;
kono
parents:
diff changeset
180 Transmission_OK : Boolean := False;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 begin
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 -- This test simulates the use of child library unit packages to implement
kono
parents:
diff changeset
185 -- a message encoding and transmission scheme. The full capability of the
kono
parents:
diff changeset
186 -- encoding and transmission mechanisms are not developed here, but the
kono
parents:
diff changeset
187 -- intent is to demonstrate that a grandchild library unit package with a
kono
parents:
diff changeset
188 -- private part will provide the framework for this type of processing.
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 Report.Test ("CA110051", "Check that entities and operations declared " &
kono
parents:
diff changeset
191 "in a package can be used in the private part " &
kono
parents:
diff changeset
192 "of a child of a child of the package");
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 -- The following code demonstrates the use
kono
parents:
diff changeset
195 -- of functionality contained in a grandchild
kono
parents:
diff changeset
196 -- library unit. The grandchild unit made use
kono
parents:
diff changeset
197 -- of components declared in the ancestor
kono
parents:
diff changeset
198 -- packages.
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 Code_Package.Send -- Message object declared
kono
parents:
diff changeset
201 (Message => Code_Package.Encode (Message), -- above in "encoded" by a
kono
parents:
diff changeset
202 Confirm => Confirmation_Message, -- call to grandchild pkg
kono
parents:
diff changeset
203 Status => Transmission_OK); -- function call, reseting
kono
parents:
diff changeset
204 -- fields and returning a
kono
parents:
diff changeset
205 -- coded message to the
kono
parents:
diff changeset
206 -- parameter. The confirm
kono
parents:
diff changeset
207 -- parameter receives an
kono
parents:
diff changeset
208 -- encoded message value
kono
parents:
diff changeset
209 -- from proc Send, which is
kono
parents:
diff changeset
210 -- "decoded"/verified below.
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 if not Code_Package.Test_Connection then
kono
parents:
diff changeset
213 Report.Failed ("Bad initialization");
kono
parents:
diff changeset
214 end if;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Verification_OK := Code_Package.Decode (Confirmation_Message);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 if not (Transmission_OK and Verification_OK) then
kono
parents:
diff changeset
219 Report.Failed ("Message transmission failure");
kono
parents:
diff changeset
220 end if;
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 Report.Result;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 end CA110051;