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