OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- C35502L.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
-- CHECK THAT 'POS' AND 'VAL' YIELD THE CORRECT RESULTS WHEN 
26
-- THE PREFIX IS A FORMAL DISCRETE TYPE WHOSE ACTUAL ARGUMENT IS
27
-- AN ENUMERATION TYPE OTHER THAN  A BOOLEAN OR A CHARACTER TYPE.
28
 
29
-- RJW 5/27/86
30
 
31
WITH REPORT; USE REPORT;
32
 
33
PROCEDURE C35502L IS
34
 
35
     TYPE ENUM IS (A, BC, ABC, A_B_C, ABCD);
36
     SUBTYPE SUBENUM IS ENUM RANGE A .. BC;
37
 
38
     TYPE NEWENUM IS NEW ENUM;
39
     SUBTYPE SUBNEW IS NEWENUM RANGE A .. BC;
40
 
41
BEGIN
42
     TEST ("C35502L", "CHECK THAT 'POS' AND 'VAL' YIELD THE " &
43
                      "CORRECT RESULTS WHEN THE PREFIX IS A " &
44
                      "FORMAL DISCRETE TYPE WHOSE ACTUAL ARGUMENT " &
45
                      "IS AN ENUMERATION TYPE OTHER THAN A " &
46
                      "CHARACTER OR A BOOLEAN TYPE" );
47
 
48
     DECLARE
49
 
50
          GENERIC
51
               TYPE E IS (<>);
52
               STR : STRING;
53
          PROCEDURE P;
54
 
55
          PROCEDURE P IS
56
               SUBTYPE SE IS E RANGE E'VAL(0) .. E'VAL(1);
57
               POSITION : INTEGER;
58
          BEGIN
59
 
60
               POSITION := 0;
61
 
62
               FOR E1 IN E
63
                    LOOP
64
                         IF SE'POS (E1) /= POSITION THEN
65
                              FAILED ( "INCORRECT SE'POS (" &
66
                                        E'IMAGE (E1) & ")" );
67
                         END IF;
68
 
69
                         IF SE'VAL (POSITION) /= E1 THEN
70
                              FAILED ( "INCORRECT " & STR & "'VAL (" &
71
                                        INTEGER'IMAGE (POSITION) &
72
                                       ")" );
73
                         END IF;
74
 
75
                         POSITION := POSITION + 1;
76
                    END LOOP;
77
 
78
               BEGIN
79
                    IF E'VAL (-1) = E'VAL (1) THEN
80
                         FAILED ( "NO EXCEPTION RAISED FOR " &
81
                                   STR & "'VAL (-1) - 1" );
82
                    ELSE
83
                         FAILED ( "NO EXCEPTION RAISED FOR " &
84
                                   STR & "'VAL (-1) - 2" );
85
                    END IF;
86
               EXCEPTION
87
                     WHEN CONSTRAINT_ERROR =>
88
                         NULL;
89
               WHEN OTHERS =>
90
                         FAILED ( "WRONG EXCEPTION RAISED FOR " &
91
                                   STR & "'VAL (-1)" );
92
               END;
93
 
94
               BEGIN
95
                    IF E'VAL (5) = E'VAL (4) THEN
96
                         FAILED ( "NO EXCEPTION RAISED FOR " &
97
                                   STR & "'VAL (5) - 1" );
98
                    ELSE
99
                         FAILED ( "NO EXCEPTION RAISED FOR " &
100
                                   STR & "'VAL (5) - 2" );
101
                    END IF;
102
               EXCEPTION
103
                    WHEN CONSTRAINT_ERROR =>
104
                         NULL;
105
                    WHEN OTHERS =>
106
                         FAILED ( "WRONG EXCEPTION RAISED FOR " &
107
                                   STR & "'VAL (5)" );
108
               END;
109
          END P;
110
 
111
          PROCEDURE PE IS NEW P ( ENUM, "ENUM" );
112
          PROCEDURE PN IS NEW P ( NEWENUM, "NEWENUM" );
113
     BEGIN
114
          PE;
115
          PN;
116
     END;
117
 
118
     DECLARE
119
          GENERIC
120
               TYPE E IS (<>);
121
          FUNCTION F (E1 : E) RETURN BOOLEAN;
122
 
123
          FUNCTION F (E1 : E) RETURN BOOLEAN IS
124
          BEGIN
125
               RETURN E'VAL (0) = E1;
126
          END F;
127
 
128
          FUNCTION FE IS NEW F (ENUM);
129
 
130
     BEGIN
131
 
132
          DECLARE
133
               FUNCTION A_B_C RETURN ENUM IS
134
               BEGIN
135
                    RETURN ENUM'VAL (IDENT_INT (0));
136
               END A_B_C;
137
          BEGIN
138
               IF FE (A_B_C) THEN
139
                    NULL;
140
               ELSE
141
                    FAILED ( "INCORRECT VAL FOR A_B_C WHEN HIDDEN " &
142
                             "BY A FUNCTION" );
143
               END IF;
144
 
145
               IF FE (C35502L.A_B_C) THEN
146
                    FAILED ( "INCORRECT VAL FOR C35502L.A_B_C" );
147
               END IF;
148
         END;
149
     END;
150
 
151
     RESULT;
152
END C35502L;

powered by: WebSVN 2.1.0

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