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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxaa012.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXAA012.A
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
--
26
-- OBJECTIVE:
27
--      Check that the exception Mode_Error is raised when an attempt is made
28
--      to read from (perform a Get_Line) or use the predefined End_Of_File
29
--      function on a text file with mode Append_File.
30
--
31
-- TEST DESCRIPTION:
32
--      A scenario is created that demonstrates the potential for the
33
--      incorrect usage of predefined text processing subprograms, resulting
34
--      from their use with files of the wrong Mode.  This results in the
35
--      raising of Mode_Error exceptions, which is handled within blocks
36
--      embedded in the test.
37
--      A count is kept to ensure that each anticipated exception is in fact
38
--      raised and handled properly.
39
--
40
-- APPLICABILITY CRITERIA:
41
--      This test is applicable only to implementations that support text
42
--      files.
43
--
44
--
45
-- CHANGE HISTORY:
46
--      06 Dec 94   SAIC    ACVC 2.0
47
--      27 Feb 97   PWB.CTA Allowed for non-support of some IO operations
48
--!
49
 
50
with Ada.Text_IO;
51
with Report;
52
 
53
procedure CXAA012 is
54
   use Ada;
55
   Text_File     : Text_IO.File_Type;
56
   Text_Filename : constant String :=
57
                      Report.Legal_File_Name ( Nam => "CXAA012" );
58
   Incomplete : exception;
59
begin
60
 
61
        Report.Test ("CXAA012", "Check that the exception Mode_Error is " &
62
                                "raised when an attempt is made to read " &
63
                                "from (perform a Get_Line) or use the "   &
64
                                "predefined End_Of_File function on a "   &
65
                                "text file with mode Append_File");
66
 
67
        Test_for_Text_IO_Support:
68
        begin
69
 
70
        -- Use_Error or Name_Error will be raised if Text_IO operations
71
        -- or external files are not supported.
72
 
73
           Text_IO.Create (Text_File, Text_IO.Out_File, Text_Filename);
74
 
75
      exception
76
          when Text_IO.Use_Error | Text_IO.Name_Error =>
77
             Report.Not_Applicable
78
                ( "Files not supported - Create as Out_File for Text_IO" );
79
             raise Incomplete;
80
      end Test_for_Text_IO_Support;
81
 
82
      -- The application writes some amount of data to the file.
83
 
84
           Text_IO.Put_Line (Text_File, "Data entered into the file");
85
 
86
           Text_IO.Close (Text_File);
87
 
88
           Operational_Test_Block:
89
           declare
90
              TC_Number_Of_Forced_Mode_Errors : constant Natural := 2;
91
              TC_Mode_Errors : Natural := 0;
92
           begin
93
 
94
              Text_IO.Open (Text_File, Text_IO.Append_File, Text_Filename);
95
 
96
              Test_for_Reading:
97
              declare
98
                 TC_Data   : String (1..80);
99
                 TC_Length : Natural := 0;
100
              begin
101
 
102
-- During the course of its processing, the application may become confused
103
-- and erroneously attempt to read data from the file that is currently in
104
-- Append_File mode (instead of the anticipated In_File mode).
105
-- This would result in the raising of Mode_Error.
106
 
107
                 Text_IO.Get_Line (Text_File, TC_Data, TC_Length);
108
                 Report.Failed ("Exception not raised by Get_Line");
109
 
110
-- An exception handler present within the application handles the exception
111
-- and processing can continue.
112
 
113
              exception
114
                 when Text_IO.Mode_Error =>
115
                    TC_Mode_Errors := TC_Mode_Errors + 1;
116
                 when others             =>
117
                    Report.Failed ("Exception in Get_Line processing");
118
              end Test_for_Reading;
119
 
120
 
121
              Test_for_End_Of_File:
122
              declare
123
                 TC_End_Of_File : Boolean;
124
              begin
125
 
126
-- Again, during the course of its processing, the application attempts to
127
-- call the End_Of_File function for the file that is currently in
128
-- Append_File mode (instead of the anticipated In_File mode).
129
 
130
                 TC_End_Of_File := Text_IO.End_Of_File (Text_File);
131
                 Report.Failed ("Exception not raised by End_Of_File");
132
 
133
-- Once again, an exception handler present within the application handles
134
-- the exception and processing continues.
135
 
136
              exception
137
                 when Text_IO.Mode_Error =>
138
                    TC_Mode_Errors := TC_Mode_Errors + 1;
139
                 when others             =>
140
                    Report.Failed("Exception in End_Of_File processing");
141
              end Test_for_End_Of_File;
142
 
143
 
144
              if (TC_Mode_Errors /= TC_Number_Of_Forced_Mode_Errors) then
145
                 Report.Failed ("Incorrect number of exceptions handled");
146
              end if;
147
 
148
           end Operational_Test_Block;
149
 
150
           -- Delete the external file.
151
           if Text_IO.Is_Open (Text_File) then
152
              Text_IO.Delete (Text_File);
153
           else
154
              Text_IO.Open (Text_File, Text_IO.In_File, Text_Filename);
155
              Text_IO.Delete (Text_File);
156
           end if;
157
 
158
        Report.Result;
159
 
160
exception
161
   when Incomplete =>
162
      Report.Result;
163
   when others     =>
164
      Report.Failed ( "Unexpected exception" );
165
      Report.Result;
166
 
167
end CXAA012;

powered by: WebSVN 2.1.0

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