1-- C45534B.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 CONSTRAINT_ERROR IS RAISED WHEN A
27--     FIXED POINT VALUE IS DIVIDED BY ZERO (EITHER AN INTEGER ZERO OR
28--     A FIXED POINT ZERO).
29
30
31-- *** NOTE: This test has been modified since ACVC version 1.11 to    -- 9X
32-- ***       remove incompatibilities associated with the transition   -- 9X
33-- ***       to Ada 9X.                                                -- 9X
34-- ***                                                                 -- 9X
35
36-- HISTORY:
37--     BCB 07/14/88  CREATED ORIGINAL TEST.
38--     MRM 03/30/93  REMOVED NUMERIC ERROR FOR 9X CONSISTENCY
39
40WITH REPORT; USE REPORT;
41
42PROCEDURE C45534B IS
43
44     TYPE FIX IS DELTA 2.0**(-1) RANGE -2.0 .. 2.0;
45     TYPE FIX2 IS DELTA 2.0**(-1) RANGE -3.0 .. 3.0;
46
47     A : FIX := 1.0;
48     B : FIX;
49     ZERO : FIX := 0.0;
50     ZERO2 : FIX2 := 0.0;
51
52     FUNCTION IDENT_FLT (ONE, TWO : FIX) RETURN BOOLEAN IS
53     BEGIN
54          RETURN ONE = FIX (TWO * FIX (IDENT_INT(1)));
55     END IDENT_FLT;
56
57BEGIN
58     TEST ("C45534B", "CHECK THAT CONSTRAINT_ERROR IS RAISED WHEN " &
59                      "A FIXED POINT VALUE IS " &
60                      "DIVIDED BY ZERO (EITHER AN INTEGER ZERO OR A " &
61                      "FIXED POINT ZERO)");
62
63     BEGIN
64          B := A / IDENT_INT (0);
65          FAILED ("NO EXCEPTION RAISED FOR DIVISION BY INTEGER ZERO");
66          IF IDENT_FLT (B,B) THEN
67               COMMENT ("DON'T OPTIMIZE B");
68          END IF;
69     EXCEPTION
70          WHEN CONSTRAINT_ERROR =>
71               NULL;
72          WHEN OTHERS =>
73               FAILED ("OTHER EXCEPTION RAISED");
74     END;
75
76     BEGIN
77          B := FIX (A / ZERO);
78          FAILED ("NO EXCEPTION RAISED FOR DIVISION BY FIXED POINT " &
79                  "ZERO - 1");
80          IF IDENT_FLT (B,B) THEN
81               COMMENT ("DON'T OPTIMIZE B");
82          END IF;
83     EXCEPTION
84          WHEN CONSTRAINT_ERROR =>
85               NULL;
86          WHEN OTHERS =>
87               FAILED ("OTHER EXCEPTION RAISED");
88      END;
89
90     BEGIN
91          B := FIX (A / ZERO2);
92          FAILED ("NO EXCEPTION RAISED FOR DIVISION BY FIXED POINT " &
93                  "ZERO - 2");
94          IF IDENT_FLT (B,B) THEN
95               COMMENT ("DON'T OPTIMIZE B");
96          END IF;
97     EXCEPTION
98          WHEN CONSTRAINT_ERROR =>
99               NULL;
100          WHEN OTHERS =>
101               FAILED ("OTHER EXCEPTION RAISED");
102      END;
103
104     RESULT;
105END C45534B;
106