1 |
294 |
jeremybenn |
-- C54A42A.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 A CASE_STATEMENT MAY HANDLE A LARGE NUMBER OF
|
26 |
|
|
-- POTENTIAL VALUES GROUPED INTO A SMALL NUMBER OF ALTERNATIVES
|
27 |
|
|
-- AND THAT EACH TIME THE APPROPRIATE ALTERNATIVE IS EXECUTED.
|
28 |
|
|
|
29 |
|
|
-- (OPTIMIZATION TEST.)
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
-- RM 03/24/81
|
33 |
|
|
-- PWN 11/30/94 SUBTYPE QUALIFIED LITERALS FOR ADA 9X.
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
WITH REPORT;
|
37 |
|
|
PROCEDURE C54A42A IS
|
38 |
|
|
|
39 |
|
|
USE REPORT ;
|
40 |
|
|
|
41 |
|
|
BEGIN
|
42 |
|
|
|
43 |
|
|
TEST( "C54A42A" , "TEST THAT A CASE_STATEMENT HANDLES CORRECTLY" &
|
44 |
|
|
" A LARGE NUMBER OF POTENTIAL VALUES GROUPED" &
|
45 |
|
|
" INTO A SMALL NUMBER OF ALTERNATIVES" );
|
46 |
|
|
|
47 |
|
|
DECLARE
|
48 |
|
|
|
49 |
|
|
STATCON : CONSTANT CHARACTER := 'B' ;
|
50 |
|
|
STATVAR : CHARACTER := 'Q' ;
|
51 |
|
|
DYNCON : CONSTANT CHARACTER := IDENT_CHAR( 'Y' );
|
52 |
|
|
DYNVAR : CHARACTER := IDENT_CHAR( 'Z' );
|
53 |
|
|
|
54 |
|
|
BEGIN
|
55 |
|
|
|
56 |
|
|
CASE CHARACTER'('A') IS
|
57 |
|
|
WHEN ASCII.NUL .. 'A' => NULL ;
|
58 |
|
|
WHEN 'B' => FAILED( "WRONG ALTERN. A2" );
|
59 |
|
|
WHEN 'P' => FAILED( "WRONG ALTERN. A3" );
|
60 |
|
|
WHEN 'Y' => FAILED( "WRONG ALTERN. A4" );
|
61 |
|
|
WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. A5" );
|
62 |
|
|
WHEN OTHERS => FAILED( "WRONG ALTERN. A6" );
|
63 |
|
|
END CASE;
|
64 |
|
|
|
65 |
|
|
CASE STATCON IS
|
66 |
|
|
WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. B1" );
|
67 |
|
|
WHEN 'B' => NULL ;
|
68 |
|
|
WHEN 'P' => FAILED( "WRONG ALTERN. B3" );
|
69 |
|
|
WHEN 'Y' => FAILED( "WRONG ALTERN. B4" );
|
70 |
|
|
WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. B5" );
|
71 |
|
|
WHEN OTHERS => FAILED( "WRONG ALTERN. B6" );
|
72 |
|
|
END CASE;
|
73 |
|
|
|
74 |
|
|
CASE STATVAR IS
|
75 |
|
|
WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. C1" );
|
76 |
|
|
WHEN 'B' => FAILED( "WRONG ALTERN. C2" );
|
77 |
|
|
WHEN 'P' => FAILED( "WRONG ALTERN. C3" );
|
78 |
|
|
WHEN 'Y' => FAILED( "WRONG ALTERN. C4" );
|
79 |
|
|
WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. C5" );
|
80 |
|
|
WHEN OTHERS => NULL ;
|
81 |
|
|
END CASE;
|
82 |
|
|
|
83 |
|
|
CASE DYNCON IS
|
84 |
|
|
WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. D1" );
|
85 |
|
|
WHEN 'B' => FAILED( "WRONG ALTERN. D2" );
|
86 |
|
|
WHEN 'P' => FAILED( "WRONG ALTERN. D3" );
|
87 |
|
|
WHEN 'Y' => NULL ;
|
88 |
|
|
WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. D5" );
|
89 |
|
|
WHEN OTHERS => FAILED( "WRONG ALTERN. D6" );
|
90 |
|
|
END CASE;
|
91 |
|
|
|
92 |
|
|
CASE DYNVAR IS
|
93 |
|
|
WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. E1" );
|
94 |
|
|
WHEN 'B' => FAILED( "WRONG ALTERN. E2" );
|
95 |
|
|
WHEN 'P' => FAILED( "WRONG ALTERN. E3" );
|
96 |
|
|
WHEN 'Y' => FAILED( "WRONG ALTERN. E4" );
|
97 |
|
|
WHEN 'Z' .. ASCII.DEL => NULL ;
|
98 |
|
|
WHEN OTHERS => FAILED( "WRONG ALTERN. E6" );
|
99 |
|
|
END CASE;
|
100 |
|
|
|
101 |
|
|
END ;
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
DECLARE
|
105 |
|
|
|
106 |
|
|
NUMBER : CONSTANT := -100 ;
|
107 |
|
|
LITEXPR : CONSTANT := 0 * NUMBER + 16 ;
|
108 |
|
|
STATCON : CONSTANT INTEGER := +100 ;
|
109 |
|
|
DYNVAR : INTEGER := IDENT_INT( 102 ) ;
|
110 |
|
|
DYNCON : CONSTANT INTEGER := IDENT_INT( 17 ) ;
|
111 |
|
|
|
112 |
|
|
BEGIN
|
113 |
|
|
|
114 |
|
|
CASE INTEGER'(-102) IS
|
115 |
|
|
WHEN INTEGER'FIRST..-101 => NULL ;
|
116 |
|
|
WHEN -100 => FAILED("WRONG ALTERN. F2");
|
117 |
|
|
WHEN 17 => FAILED("WRONG ALTERN. F2");
|
118 |
|
|
WHEN 100 => FAILED("WRONG ALTERN. F4");
|
119 |
|
|
WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. F5");
|
120 |
|
|
WHEN OTHERS => FAILED("WRONG ALTERN. F6");
|
121 |
|
|
END CASE;
|
122 |
|
|
|
123 |
|
|
CASE IDENT_INT(NUMBER) IS
|
124 |
|
|
WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. G1");
|
125 |
|
|
WHEN -100 => NULL ;
|
126 |
|
|
WHEN 17 => FAILED("WRONG ALTERN. G3");
|
127 |
|
|
WHEN 100 => FAILED("WRONG ALTERN. G4");
|
128 |
|
|
WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. G5");
|
129 |
|
|
WHEN OTHERS => FAILED("WRONG ALTERN. G6");
|
130 |
|
|
END CASE;
|
131 |
|
|
|
132 |
|
|
CASE IDENT_INT(LITEXPR) IS
|
133 |
|
|
WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. H1");
|
134 |
|
|
WHEN -100 => FAILED("WRONG ALTERN. H2");
|
135 |
|
|
WHEN 17 => FAILED("WRONG ALTERN. H3");
|
136 |
|
|
WHEN 100 => FAILED("WRONG ALTERN. H4");
|
137 |
|
|
WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. H5");
|
138 |
|
|
WHEN OTHERS => NULL ;
|
139 |
|
|
END CASE;
|
140 |
|
|
|
141 |
|
|
CASE STATCON IS
|
142 |
|
|
WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. I1");
|
143 |
|
|
WHEN -100 => FAILED("WRONG ALTERN. I2");
|
144 |
|
|
WHEN 17 => FAILED("WRONG ALTERN. I3");
|
145 |
|
|
WHEN 100 => NULL ;
|
146 |
|
|
WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. I5");
|
147 |
|
|
WHEN OTHERS => FAILED("WRONG ALTERN. I6");
|
148 |
|
|
END CASE;
|
149 |
|
|
|
150 |
|
|
CASE DYNVAR IS
|
151 |
|
|
WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. J1");
|
152 |
|
|
WHEN -100 => FAILED("WRONG ALTERN. J2");
|
153 |
|
|
WHEN 17 => FAILED("WRONG ALTERN. J3");
|
154 |
|
|
WHEN 100 => FAILED("WRONG ALTERN. J4");
|
155 |
|
|
WHEN 101..INTEGER'LAST => NULL ;
|
156 |
|
|
WHEN OTHERS => FAILED("WRONG ALTERN. J6");
|
157 |
|
|
END CASE;
|
158 |
|
|
|
159 |
|
|
CASE DYNCON IS
|
160 |
|
|
WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. K1");
|
161 |
|
|
WHEN -100 => FAILED("WRONG ALTERN. K2");
|
162 |
|
|
WHEN 17 => NULL ;
|
163 |
|
|
WHEN 100 => FAILED("WRONG ALTERN. K4");
|
164 |
|
|
WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. K5");
|
165 |
|
|
WHEN OTHERS => FAILED("WRONG ALTERN. K6");
|
166 |
|
|
END CASE;
|
167 |
|
|
END ;
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
RESULT ;
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
END C54A42A ;
|