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/] [c35502m.ada] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- C35502M.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 'POS' AND 'VAL' YIELD THE CORRECT RESULTS WHEN
27
--     THE PREFIX IS AN ENUMERATION TYPE, OTHER THAN A BOOLEAN OR A
28
--     CHARACTER TYPE, WITH AN ENUMERATION REPRESENTATION CLAUSE.
29
 
30
-- HISTORY:
31
--     RJW 05/27/86  CREATED ORIGINAL TEST.
32
--     BCB 01/04/88  MODIFIED HEADER.
33
--     PWB 05/11/89  CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
34
 
35
WITH REPORT; USE REPORT;
36
 
37
PROCEDURE C35502M IS
38
 
39
     TYPE ENUM IS (A, BC, ABC, A_B_C, ABCD);
40
     FOR ENUM USE (A => 2, BC => 4, ABC => 6,
41
                   A_B_C => 8, ABCD => 10);
42
 
43
     SUBTYPE SUBENUM IS ENUM RANGE A .. BC;
44
 
45
     TYPE NEWENUM IS NEW ENUM;
46
     SUBTYPE SUBNEW IS NEWENUM RANGE A .. BC;
47
 
48
BEGIN
49
     TEST ("C35502M", "CHECK THAT 'POS' AND 'VAL' YIELD THE " &
50
                      "CORRECT RESULTS WHEN THE PREFIX IS AN " &
51
                      "ENUMERATION TYPE, OTHER THAN A CHARACTER " &
52
                      "OR A BOOLEAN TYPE, WITH AN ENUMERATION " &
53
                      "REPRESENTATION CLAUSE" );
54
 
55
     DECLARE
56
          POSITION : INTEGER;
57
     BEGIN
58
          POSITION := 0;
59
 
60
          FOR E IN ENUM
61
               LOOP
62
                    IF SUBENUM'POS (E) /= POSITION THEN
63
                         FAILED ( "INCORRECT SUBENUM'POS (" &
64
                                   ENUM'IMAGE (E) & ")" );
65
                    END IF;
66
 
67
                    IF SUBENUM'VAL (POSITION) /= E THEN
68
                         FAILED ( "INCORRECT SUBENUM'VAL (" &
69
                                   INTEGER'IMAGE (POSITION) &
70
                                  ")" );
71
                    END IF;
72
 
73
                    POSITION := POSITION + 1;
74
               END LOOP;
75
 
76
          POSITION := 0;
77
          FOR E IN NEWENUM
78
               LOOP
79
                    IF SUBNEW'POS (E) /= POSITION THEN
80
                         FAILED ( "INCORRECT SUBNEW'POS (" &
81
                                   NEWENUM'IMAGE (E) & ")" );
82
                    END IF;
83
 
84
                    IF SUBNEW'VAL (POSITION) /= E THEN
85
                         FAILED ( "INCORRECT SUBNEW'VAL (" &
86
                                   INTEGER'IMAGE (POSITION) &
87
                                  ")" );
88
                    END IF;
89
 
90
                    POSITION := POSITION + 1;
91
               END LOOP;
92
     END;
93
 
94
     DECLARE
95
          FUNCTION A_B_C RETURN ENUM IS
96
          BEGIN
97
               RETURN A;
98
          END A_B_C;
99
 
100
     BEGIN
101
          IF ENUM'VAL (0) /= A_B_C THEN
102
               FAILED ( "WRONG ENUM'VAL (0) WHEN HIDDEN " &
103
                        "BY FUNCTION - 1" );
104
          END IF;
105
 
106
          IF ENUM'VAL (0) = C35502M.A_B_C THEN
107
               FAILED ( "WRONG ENUM'VAL (0) WHEN HIDDEN " &
108
                        "BY FUNCTION - 2" );
109
          END IF;
110
     END;
111
 
112
     BEGIN
113
          IF ENUM'VAL (IDENT_INT (-1)) = ENUM'FIRST THEN
114
               FAILED ( "NO EXCEPTION RAISED FOR " &
115
                        "ENUM'VAL (IDENT_INT (-1)) - 1" );
116
          ELSE
117
               FAILED ( "NO EXCEPTION RAISED FOR " &
118
                        "ENUM'VAL (IDENT_INT (-1)) - 2" );
119
          END IF;
120
     EXCEPTION
121
          WHEN CONSTRAINT_ERROR =>
122
               NULL;
123
          WHEN OTHERS =>
124
               FAILED ( "WRONG EXCEPTION RAISED FOR " &
125
                        "ENUM'VAL (IDENT_INT (-1))" );
126
     END;
127
 
128
     BEGIN
129
          IF NEWENUM'VAL (IDENT_INT (-1)) = NEWENUM'LAST THEN
130
               FAILED ( "NO EXCEPTION RAISED FOR " &
131
                        "NEWENUM'VAL (IDENT_INT (-1)) - 1" );
132
          ELSE
133
               FAILED ( "NO EXCEPTION RAISED FOR " &
134
                        "NEWENUM'VAL (IDENT_INT (-1)) - 2" );
135
          END IF;
136
     EXCEPTION
137
          WHEN CONSTRAINT_ERROR =>
138
               NULL;
139
          WHEN OTHERS =>
140
               FAILED ( "WRONG EXCEPTION RAISED FOR " &
141
                        "NEWENUM'VAL (IDENT_INT (-1))" );
142
     END;
143
 
144
     BEGIN
145
          IF ENUM'VAL (IDENT_INT (5)) = ENUM'LAST THEN
146
               FAILED ( "NO EXCEPTION RAISED FOR " &
147
                        "ENUM'VAL (IDENT_INT (5)) - 1" );
148
          ELSE
149
               FAILED ( "NO EXCEPTION RAISED FOR " &
150
                        "ENUM'VAL (IDENT_INT (5)) - 2" );
151
          END IF;
152
     EXCEPTION
153
          WHEN CONSTRAINT_ERROR =>
154
               NULL;
155
          WHEN OTHERS =>
156
               FAILED ( "WRONG EXCEPTION RAISED FOR " &
157
                        "ENUM'VAL (IDENT_INT (5))" );
158
     END;
159
 
160
     BEGIN
161
          IF NEWENUM'VAL (IDENT_INT (5)) = NEWENUM'LAST THEN
162
               FAILED ( "NO EXCEPTION RAISED FOR " &
163
                        "NEWENUM'VAL (IDENT_INT (5)) - 1" );
164
          ELSE
165
               FAILED ( "NO EXCEPTION RAISED FOR " &
166
                        "NEWENUM'VAL (IDENT_INT (5)) - 2" );
167
          END IF;
168
     EXCEPTION
169
          WHEN CONSTRAINT_ERROR =>
170
               NULL;
171
          WHEN OTHERS =>
172
               FAILED ( "WRONG EXCEPTION RAISED FOR " &
173
                        "NEWENUM'VAL (IDENT_INT (5))" );
174
     END;
175
 
176
     RESULT;
177
END C35502M;

powered by: WebSVN 2.1.0

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