OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c34007r.ada] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- C34007R.ADA
2
 
3
--                             Grant of Unlimited Rights
4
--
5
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained 
7
--     unlimited rights in the software and documentation contained herein.
8
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making 
9
--     this public release, the Government intends to confer upon all 
10
--     recipients unlimited rights  equal to those held by the Government.  
11
--     These rights include rights to use, duplicate, release or disclose the 
12
--     released technical data and computer software in whole or in part, in 
13
--     any manner and for any purpose whatsoever, and to have or permit others 
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
18
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED 
20
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE 
22
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23
--     PARTICULAR PURPOSE OF SAID MATERIAL.
24
--*
25
-- FOR DERIVED ACCESS TYPES WHOSE DESIGNATED TYPE IS A RECORD TYPE
26
-- WITH DISCRIMINANTS:
27
 
28
--   CHECK THAT ALL VALUES OF THE PARENT (BASE) TYPE ARE PRESENT FOR THE
29
--   DERIVED (BASE) TYPE WHEN THE DERIVED TYPE DEFINITION IS
30
--   CONSTRAINED.
31
 
32
--   CHECK THAT ANY CONSTRAINT IMPOSED ON THE PARENT SUBTYPE IS ALSO
33
--   IMPOSED ON THE DERIVED SUBTYPE.
34
 
35
-- JRK 9/29/86
36
 
37
WITH REPORT; USE REPORT;
38
 
39
PROCEDURE C34007R IS
40
 
41
     SUBTYPE COMPONENT IS INTEGER;
42
 
43
     SUBTYPE LENGTH IS NATURAL RANGE 0 .. 10;
44
 
45
     TYPE DESIGNATED (B : BOOLEAN := TRUE; L : LENGTH := 1) IS
46
          RECORD
47
               I : INTEGER;
48
               CASE B IS
49
                    WHEN TRUE =>
50
                         S : STRING (1 .. L);
51
                         C : COMPONENT;
52
                    WHEN FALSE =>
53
                         F : FLOAT := 5.0;
54
               END CASE;
55
          END RECORD;
56
 
57
     PACKAGE PKG IS
58
 
59
          TYPE PARENT IS ACCESS DESIGNATED;
60
 
61
          FUNCTION CREATE ( B : BOOLEAN;
62
                            L : LENGTH;
63
                            I : INTEGER;
64
                            S : STRING;
65
                            C : COMPONENT;
66
                            F : FLOAT;
67
                            X : PARENT  -- TO RESOLVE OVERLOADING.
68
                          ) RETURN PARENT;
69
 
70
     END PKG;
71
 
72
     USE PKG;
73
 
74
     TYPE T IS NEW PARENT (IDENT_BOOL (TRUE), IDENT_INT (3));
75
 
76
     SUBTYPE SUBPARENT IS PARENT (TRUE, 3);
77
 
78
     TYPE S IS NEW SUBPARENT;
79
 
80
     X : T := NEW DESIGNATED'(TRUE, 3, 2, "AAA", 2);
81
     Y : S := NEW DESIGNATED'(TRUE, 3, 2, "AAA", 2);
82
 
83
     PACKAGE BODY PKG IS
84
 
85
          FUNCTION CREATE
86
             ( B : BOOLEAN;
87
               L : LENGTH;
88
               I : INTEGER;
89
               S : STRING;
90
               C : COMPONENT;
91
               F : FLOAT;
92
               X : PARENT
93
             ) RETURN PARENT
94
          IS
95
          BEGIN
96
               CASE B IS
97
                    WHEN TRUE =>
98
                         RETURN NEW DESIGNATED'(TRUE, L, I, S, C);
99
                    WHEN FALSE =>
100
                         RETURN NEW DESIGNATED'(FALSE, L, I, F);
101
               END CASE;
102
          END CREATE;
103
 
104
     END PKG;
105
 
106
BEGIN
107
     TEST ("C34007R", "CHECK THAT ALL VALUES OF THE PARENT (BASE) " &
108
                      "TYPE ARE PRESENT FOR THE DERIVED (BASE) TYPE " &
109
                      "WHEN THE DERIVED TYPE DEFINITION IS " &
110
                      "CONSTRAINED.  ALSO CHECK THAT ANY CONSTRAINT " &
111
                      "IMPOSED ON THE PARENT SUBTYPE IS ALSO IMPOSED " &
112
                      "ON THE DERIVED SUBTYPE.  CHECK FOR DERIVED " &
113
                      "ACCESS TYPES WHOSE DESIGNATED TYPE IS A " &
114
                      "RECORD TYPE WITH DISCRIMINANTS");
115
 
116
     -- CHECK THAT BASE TYPE VALUES NOT IN THE SUBTYPE ARE PRESENT.
117
 
118
     IF CREATE (FALSE, 2, 3, "ZZ", 5, 6.0, X) . ALL /=
119
        (FALSE, 2, 3, 6.0) OR
120
        CREATE (FALSE, 2, 3, "ZZ", 5, 6.0, Y) . ALL /=
121
        (FALSE, 2, 3, 6.0) THEN
122
          FAILED ("CAN'T CREATE BASE TYPE VALUES OUTSIDE THE SUBTYPE");
123
     END IF;
124
 
125
     IF CREATE (FALSE, 2, 3, "ZZ", 5, 6.0, X) IN T OR
126
        CREATE (FALSE, 2, 3, "ZZ", 5, 6.0, Y) IN S THEN
127
          FAILED ("INCORRECT ""IN""");
128
     END IF;
129
 
130
     -- CHECK THE DERIVED SUBTYPE CONSTRAINT.
131
 
132
     IF X.B /= TRUE OR X.L /= 3 OR
133
        Y.B /= TRUE OR Y.L /= 3 THEN
134
          FAILED ("INCORRECT SELECTION OF DISCRIMINANT VALUES");
135
     END IF;
136
 
137
     BEGIN
138
          X := NEW DESIGNATED'(TRUE, 3, 1, "ABC", 4);
139
          Y := NEW DESIGNATED'(TRUE, 3, 1, "ABC", 4);
140
          IF PARENT (X) = PARENT (Y) OR  -- USE X AND Y.
141
             X.ALL /= Y.ALL THEN
142
               FAILED ("INCORRECT ALLOCATOR OR CONVERSION TO PARENT");
143
          END IF;
144
     EXCEPTION
145
          WHEN OTHERS =>
146
               FAILED ("EXCEPTION RAISED BY OK ASSIGNMENT");
147
     END;
148
 
149
     BEGIN
150
          X := NEW DESIGNATED'(FALSE, 3, 2, 6.0);
151
          FAILED ("CONSTRAINT_ERROR NOT RAISED -- " &
152
                  "X := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
153
          IF X = NULL OR ELSE X.ALL = (FALSE, 3, 2, 6.0) THEN  -- USE X.
154
               COMMENT ("X ALTERED -- " &
155
                        "X := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
156
          END IF;
157
     EXCEPTION
158
          WHEN CONSTRAINT_ERROR =>
159
               NULL;
160
          WHEN OTHERS =>
161
               FAILED ("WRONG EXCEPTION RAISED -- " &
162
                       "X := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
163
     END;
164
 
165
     BEGIN
166
          X := NEW DESIGNATED'(TRUE, 4, 2, "ZZZZ", 6);
167
          FAILED ("CONSTRAINT_ERROR NOT RAISED -- " &
168
                  "X := NEW DESIGNATED'(TRUE, 4, 2, ""ZZZZ"", 6)");
169
          IF X = NULL OR ELSE
170
             X.ALL = (TRUE, 4, 2, "ZZZZ", 6) THEN  -- USE X.
171
               COMMENT ("X ALTERED -- " &
172
                        "X := NEW DESIGNATED'" &
173
                        "(TRUE, 4, 2, ""ZZZZ"", 6)");
174
          END IF;
175
     EXCEPTION
176
          WHEN CONSTRAINT_ERROR =>
177
               NULL;
178
          WHEN OTHERS =>
179
               FAILED ("WRONG EXCEPTION RAISED -- " &
180
                       "X := NEW DESIGNATED'(TRUE, 4, 2, ""ZZZZ"", 6)");
181
     END;
182
 
183
     BEGIN
184
          Y := NEW DESIGNATED'(FALSE, 3, 2, 6.0);
185
          FAILED ("CONSTRAINT_ERROR NOT RAISED -- " &
186
                  "Y := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
187
          IF Y = NULL OR ELSE Y.ALL = (FALSE, 3, 2, 6.0) THEN  -- USE Y.
188
               COMMENT ("Y ALTERED -- " &
189
                        "Y := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
190
          END IF;
191
     EXCEPTION
192
          WHEN CONSTRAINT_ERROR =>
193
               NULL;
194
          WHEN OTHERS =>
195
               FAILED ("WRONG EXCEPTION RAISED -- " &
196
                       "Y := NEW DESIGNATED'(FALSE, 3, 2, 6.0)");
197
     END;
198
 
199
     BEGIN
200
          Y := NEW DESIGNATED'(TRUE, 4, 2, "ZZZZ", 6);
201
          FAILED ("CONSTRAINT_ERROR NOT RAISED -- " &
202
                  "Y := NEW DESIGNATED'(TRUE, 4, 2, ""ZZZZ"", 6)");
203
          IF Y = NULL OR ELSE
204
             Y.ALL = (TRUE, 4, 2, "ZZZZ", 6) THEN  -- USE Y.
205
               COMMENT ("Y ALTERED -- " &
206
                        "Y := NEW DESIGNATED'" &
207
                        "(TRUE, 4, 2, ""ZZZZ"", 6)");
208
          END IF;
209
     EXCEPTION
210
          WHEN CONSTRAINT_ERROR =>
211
               NULL;
212
          WHEN OTHERS =>
213
               FAILED ("WRONG EXCEPTION RAISED -- " &
214
                       "Y := NEW DESIGNATED'(TRUE, 4, 2, ""ZZZZ"", 6)");
215
     END;
216
 
217
     RESULT;
218
END C34007R;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.