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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cd/] [cda201e.ada] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
-- CDA201E.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 UNCHECKED_CONVERSION CAN BE INSTANTIATED FOR THE
27
--     CONVERSION OF AN ENUMERATION TYPE WITH A REPRESENTATION CLAUSE TO
28
--     INTEGER.
29
 
30
-- HISTORY:
31
--     JET 09/23/88  CREATED ORIGINAL TEST.
32
--     DHH 05/17/89  CHANGED FROM '.DEP' TEST TO '.ADA' TEST.
33
--     RJW 02/28/90  ADDED SIZE CLAUSE FOR TYPE STOOGE.
34
--     LDC 09/20/90  ADDED CHECK FOR CONVERSION FROM INT TO STOOGE,
35
--                   ADDED COMMENT WHEN SIZES AREN'T EQUAL.
36
 
37
WITH REPORT; USE REPORT;
38
WITH UNCHECKED_CONVERSION;
39
PROCEDURE CDA201E IS
40
 
41
     TYPE STOOGE IS (CURLY, MOE, LARRY);
42
     FOR STOOGE USE (CURLY => -5, MOE => 13, LARRY => 127);
43
     FOR STOOGE'SIZE USE 8;
44
 
45
     TYPE INT IS RANGE -128 .. 127;
46
     FOR INT'SIZE USE 8;
47
 
48
     I    : INT := 0;
49
     NAME : STOOGE := CURLY;
50
 
51
     FUNCTION E_TO_I IS NEW UNCHECKED_CONVERSION(STOOGE, INT);
52
     FUNCTION I_TO_E IS NEW UNCHECKED_CONVERSION(INT, STOOGE);
53
 
54
     FUNCTION ID(E : STOOGE) RETURN STOOGE IS
55
     BEGIN
56
          RETURN STOOGE'VAL(STOOGE'POS(E) + IDENT_INT(0));
57
     END ID;
58
 
59
     FUNCTION ID_INT (X : INT) RETURN INT IS
60
          A : INTEGER := IDENT_INT(3);
61
     BEGIN
62
          IF EQUAL (A, IDENT_INT(3)) THEN    -- ALWAYS EQUAL.
63
               RETURN X;                     -- ALWAYS EXECUTED.
64
          END IF;
65
          RETURN 0;                          -- NEVER EXECUTED.
66
     END ID_INT;
67
 
68
BEGIN
69
     TEST ("CDA201E", "CHECK THAT UNCHECKED_CONVERSION CAN BE " &
70
                      "INSTANTIATED FOR THE CONVERSION OF AN " &
71
                      "ENUMERATION TYPE WITH A REPRESENTATION " &
72
                      "CLAUSE TO INTEGER");
73
 
74
     IF I'SIZE /= NAME'SIZE THEN
75
          COMMENT( "UNCHECKED_CONVERSION MIGHT BE INSTANTIATED WITH " &
76
                   "DIFFERNT SIZES");
77
     END IF;
78
 
79
     BEGIN
80
          I := E_TO_I(ID(CURLY));
81
          IF I /= -5 THEN
82
               FAILED ("INCORRECT VALUE OF CURLY: " & INT'IMAGE(I));
83
          END IF;
84
 
85
          I := E_TO_I(ID(MOE));
86
          IF I /= 13 THEN
87
               FAILED ("INCORRECT VALUE OF MOE: " & INT'IMAGE(I));
88
          END IF;
89
 
90
          I := E_TO_I(ID(LARRY));
91
          IF I /= 127 THEN
92
               FAILED ("INCORRECT VALUE OF LARRY: " & INT'IMAGE(I));
93
          END IF;
94
     EXCEPTION
95
          WHEN OTHERS =>
96
               FAILED ("UNEXPECTED EXCEPTION RAISED BY CONVERSION");
97
     END;
98
 
99
     BEGIN     -- 2
100
          NAME := I_TO_E(ID_INT(-5));
101
          IF NAME /= CURLY THEN
102
               FAILED ("INCORRECT VALUE OF -5 : " & STOOGE'IMAGE(NAME));
103
          END IF;
104
 
105
          NAME := I_TO_E(ID_INT(13));
106
          IF NAME /= MOE THEN
107
               FAILED ("INCORRECT VALUE OF 13: " & STOOGE'IMAGE(NAME));
108
          END IF;
109
 
110
          NAME := I_TO_E(ID_INT(127));
111
          IF NAME /= LARRY THEN
112
               FAILED ("INCORRECT VALUE OF 127: " & STOOGE'IMAGE(NAME));
113
          END IF;
114
     EXCEPTION
115
          WHEN OTHERS =>
116
               FAILED ("UNEXPECTED EXCEPTION RAISED BY CONVERSION - 2");
117
     END;
118
 
119
     RESULT;
120
END CDA201E;

powered by: WebSVN 2.1.0

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