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/] [cd/] [cd2a21e.ada] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CD2A21E.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
-- OBJECTIVE:
26
--     CHECK THAT WHEN A SIZE SPECIFICATION IS GIVEN FOR AN
27
--     ENUMERATION TYPE, THEN SUCH A TYPE CAN
28
--     BE PASSED AS AN ACTUAL PARAMETER TO A GENERIC PROCEDURE.
29
 
30
-- HISTORY:
31
--     JET 08/18/87 CREATED ORIGINAL TEST.
32
--     DHH 04/17/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA', CHANGED
33
--                  OPERATORS ON 'SIZE TESTS, AND ADDED CHECK ON
34
--                  REPRESENTATION CLAUSE.
35
--     BCB 03/05/90 ADDED CALL TO LENGTH_CHECK TO VERIFY THAT THE SIZE
36
--                  SPECIFICATION IS OBEYED.
37
--     LDC 10/03/90 ADDED CASES FOR >=, /=, ASSIGNMENT, QUALIFICATION, 
38
--                  AND EXPLICIT CONVERSION.
39
--     JRL 03/26/92 ELIMINATED REDUNDANT TESTING.
40
 
41
WITH REPORT; USE REPORT;
42
WITH LENGTH_CHECK;                      -- CONTAINS A CALL TO 'FAILED'.
43
PROCEDURE CD2A21E IS
44
 
45
     TYPE BASIC_ENUM IS (ZERO, ONE, TWO);
46
     BASIC_SIZE : CONSTANT := INTEGER'SIZE / 2;
47
 
48
     FOR BASIC_ENUM'SIZE USE BASIC_SIZE;
49
 
50
BEGIN
51
     TEST ("CD2A21E", "CHECK THAT WHEN A SIZE SPECIFICATION IS " &
52
                      "GIVEN FOR AN ENUMERATION TYPE, " &
53
                      "THEN SUCH A TYPE CAN BE " &
54
                      "PASSED AS AN ACTUAL PARAMETER TO A GENERIC " &
55
                      "PROCEDURE");
56
 
57
     DECLARE -- TYPE DECLARATION GIVEN WITHIN GENERIC PROCEDURE.
58
 
59
          GENERIC
60
               TYPE GPARM IS (<>);
61
          PROCEDURE GENPROC (C0, C1, C2: GPARM);
62
 
63
          PROCEDURE GENPROC (C0, C1, C2: GPARM) IS
64
 
65
               SUBTYPE CHECK_TYPE IS GPARM;
66
 
67
               C3 : GPARM;
68
 
69
               CHECKVAR : CHECK_TYPE;
70
 
71
               PROCEDURE CHECK_1 IS NEW LENGTH_CHECK (CHECK_TYPE);
72
 
73
               FUNCTION IDENT (CH : CHECK_TYPE) RETURN CHECK_TYPE IS
74
               BEGIN
75
                    IF EQUAL (3, 3) THEN
76
                         RETURN CH;
77
                    ELSE
78
                         RETURN C1;
79
                    END IF;
80
               END IDENT;
81
 
82
          BEGIN -- GENPROC.
83
 
84
               CHECKVAR := IDENT (C0);
85
 
86
               CHECK_1 (CHECKVAR, CHECK_TYPE'SIZE, "CHECK_TYPE");
87
 
88
               IF CHECK_TYPE'SIZE /= IDENT_INT (BASIC_SIZE) THEN
89
                    FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SIZE");
90
               END IF;
91
 
92
               IF C0'SIZE < IDENT_INT (BASIC_SIZE) THEN
93
                    FAILED ("INCORRECT VALUE FOR C0'SIZE");
94
               END IF;
95
 
96
               IF NOT ((IDENT (C1) IN C1 .. C2)       AND
97
                       (IDENT(C0) NOT IN IDENT (C1) .. C2)) THEN
98
                    FAILED ("INCORRECT RESULTS FOR MEMBERSHIP " &
99
                            "OPERATORS");
100
               END IF;
101
 
102
               IF CHECK_TYPE'LAST /= IDENT (C2) THEN
103
                    FAILED ("INCORRECT VALUE FOR CHECK_TYPE'LAST");
104
               END IF;
105
 
106
               IF CHECK_TYPE'VAL (0) /= IDENT (C0) OR
107
                  CHECK_TYPE'VAL (1) /= IDENT (C1) OR
108
                  CHECK_TYPE'VAL (2) /= IDENT (C2) THEN
109
                    FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VAL");
110
               END IF;
111
 
112
               IF CHECK_TYPE'PRED (C1) /= IDENT (C0) OR
113
                  CHECK_TYPE'PRED (C2) /= IDENT (C1) THEN
114
                    FAILED ("INCORRECT VALUE FOR CHECK_TYPE'PRED");
115
               END IF;
116
 
117
               IF CHECK_TYPE'VALUE ("ZERO") /= IDENT (C0)  OR
118
                  CHECK_TYPE'VALUE ("ONE")  /=  IDENT (C1) OR
119
                  CHECK_TYPE'VALUE ("TWO")  /=  IDENT (C2) THEN
120
                    FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VALUE");
121
               END IF;
122
 
123
               CHECKVAR := CHECK_TYPE'VALUE ("ONE");
124
               C3 := GPARM(CHECKVAR);
125
               IF C3 /= IDENT(C1) THEN
126
                    FAILED ("INCORRECT VALUE FOR CONVERSION");
127
               END IF;
128
 
129
               CHECK_1 (IDENT(C0), BASIC_SIZE, "CHECK_ENUM");
130
 
131
 
132
               IF CHECK_TYPE'(C2) /= IDENT(C2) THEN
133
                    FAILED ("INCORRECT VALUE FOR QUALIFICATION");
134
               END IF;
135
 
136
               C3 := CHECK_TYPE'VALUE ("TWO");
137
               IF C3 /= IDENT(C2) THEN
138
                    FAILED ("INCORRECT VALUE FOR ASSIGNMENT");
139
               END IF;
140
 
141
          END GENPROC;
142
 
143
          PROCEDURE NEWPROC IS NEW GENPROC (BASIC_ENUM);
144
 
145
     BEGIN
146
 
147
          NEWPROC (ZERO, ONE, TWO);
148
 
149
     END;
150
 
151
     RESULT;
152
 
153
END CD2A21E;

powered by: WebSVN 2.1.0

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