-- CXAC003.A
|
-- CXAC003.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the correct exceptions are raised when improperly
|
-- Check that the correct exceptions are raised when improperly
|
-- manipulating stream file objects.
|
-- manipulating stream file objects.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test is designed to focus on Stream_IO file manipulation
|
-- This test is designed to focus on Stream_IO file manipulation
|
-- exceptions. Several potentially common user errors are examined in
|
-- exceptions. Several potentially common user errors are examined in
|
-- the test:
|
-- the test:
|
--
|
--
|
-- A Status_Error should be raised whenever an attempt is made to perform
|
-- A Status_Error should be raised whenever an attempt is made to perform
|
-- an operation on a file that is closed.
|
-- an operation on a file that is closed.
|
--
|
--
|
-- A Status_Error should be raised when an attempt is made to open a
|
-- A Status_Error should be raised when an attempt is made to open a
|
-- stream file that is currently open.
|
-- stream file that is currently open.
|
--
|
--
|
-- A Mode_Error should be raised when attempting to read from (use the
|
-- A Mode_Error should be raised when attempting to read from (use the
|
-- 'Read attribute) on an Out_File or Append_Mode file.
|
-- 'Read attribute) on an Out_File or Append_Mode file.
|
--
|
--
|
-- A Mode_Error should be raised when checking for End Of File on a
|
-- A Mode_Error should be raised when checking for End Of File on a
|
-- file with mode Out_File or Append_Mode.
|
-- file with mode Out_File or Append_Mode.
|
--
|
--
|
-- A Mode_Error should be raised when attempting to write to (use the
|
-- A Mode_Error should be raised when attempting to write to (use the
|
-- 'Output attribute) on a file with mode In_File.
|
-- 'Output attribute) on a file with mode In_File.
|
--
|
--
|
-- A Name_Error should be raised when the string provided to the Name
|
-- A Name_Error should be raised when the string provided to the Name
|
-- parameter of an Open operation does not allow association of an
|
-- parameter of an Open operation does not allow association of an
|
-- external file.
|
-- external file.
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- This test is applicable to all implementations capable of supporting
|
-- This test is applicable to all implementations capable of supporting
|
-- external Stream_IO files.
|
-- external Stream_IO files.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
-- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
-- 02 Mar 01 PHL Check that Ada.Streams.Stream_IO.Stream raises
|
-- 02 Mar 01 PHL Check that Ada.Streams.Stream_IO.Stream raises
|
-- Status_Error if the file is not open. (DR 8652/
|
-- Status_Error if the file is not open. (DR 8652/
|
-- 0056).
|
-- 0056).
|
-- 15 Mar 01 RLB Readied for release.
|
-- 15 Mar 01 RLB Readied for release.
|
--!
|
--!
|
|
|
with Ada.Streams.Stream_IO;
|
with Ada.Streams.Stream_IO;
|
with Report;
|
with Report;
|
|
|
procedure CXAC003 is
|
procedure CXAC003 is
|
|
|
Stream_File_Object : Ada.Streams.Stream_IO.File_Type;
|
Stream_File_Object : Ada.Streams.Stream_IO.File_Type;
|
Stream_Access_Value : Ada.Streams.Stream_IO.Stream_Access;
|
Stream_Access_Value : Ada.Streams.Stream_IO.Stream_Access;
|
Stream_Filename : constant String :=
|
Stream_Filename : constant String :=
|
Report.Legal_File_Name ( Nam => "CXAC003" );
|
Report.Legal_File_Name ( Nam => "CXAC003" );
|
Incomplete : exception;
|
Incomplete : exception;
|
|
|
begin
|
begin
|
|
|
Report.Test ("CXAC003", "Check that the correct exceptions are " &
|
Report.Test ("CXAC003", "Check that the correct exceptions are " &
|
"raised when improperly manipulating stream " &
|
"raised when improperly manipulating stream " &
|
"file objects");
|
"file objects");
|
|
|
Test_for_Stream_IO_Support:
|
Test_for_Stream_IO_Support:
|
begin
|
begin
|
-- If an implementation does not support Stream_IO in a particular
|
-- If an implementation does not support Stream_IO in a particular
|
-- environment, the exception Use_Error or Name_Error will be raised on
|
-- environment, the exception Use_Error or Name_Error will be raised on
|
-- calls to various Stream_IO operations. This block statement
|
-- calls to various Stream_IO operations. This block statement
|
-- encloses a call to Create, which should produce an exception in a
|
-- encloses a call to Create, which should produce an exception in a
|
-- non-supportive environment. These exceptions will be handled to
|
-- non-supportive environment. These exceptions will be handled to
|
-- produce a Not_Applicable result.
|
-- produce a Not_Applicable result.
|
|
|
Ada.Streams.Stream_IO.Create (Stream_File_Object,
|
Ada.Streams.Stream_IO.Create (Stream_File_Object,
|
Ada.Streams.Stream_IO.Out_File,
|
Ada.Streams.Stream_IO.Out_File,
|
Stream_Filename);
|
Stream_Filename);
|
|
|
exception
|
exception
|
|
|
when Ada.Streams.Stream_IO.Use_Error | Ada.Streams.Stream_IO.Name_Error =>
|
when Ada.Streams.Stream_IO.Use_Error | Ada.Streams.Stream_IO.Name_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Files not supported - Create as Out_File for Stream_IO" );
|
( "Files not supported - Create as Out_File for Stream_IO" );
|
raise Incomplete;
|
raise Incomplete;
|
|
|
end Test_for_Stream_IO_Support;
|
end Test_for_Stream_IO_Support;
|
|
|
Operational_Test_Block:
|
Operational_Test_Block:
|
begin
|
begin
|
-- A potentially common error in a file processing environment
|
-- A potentially common error in a file processing environment
|
-- is to attempt to perform an operation on a stream file that is
|
-- is to attempt to perform an operation on a stream file that is
|
-- not currently open. Status_Error should be raised in this case.
|
-- not currently open. Status_Error should be raised in this case.
|
Check_Status_Error:
|
Check_Status_Error:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Close (Stream_File_Object);
|
Ada.Streams.Stream_IO.Close (Stream_File_Object);
|
-- Attempt to reset a file that is closed.
|
-- Attempt to reset a file that is closed.
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Out_File);
|
Ada.Streams.Stream_IO.Out_File);
|
Report.Failed ("Exception not raised on Reset of closed file");
|
Report.Failed ("Exception not raised on Reset of closed file");
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Status_Error =>
|
when Ada.Streams.Stream_IO.Status_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 1");
|
Report.Failed ("Incorrect exception raised - 1");
|
end Check_Status_Error;
|
end Check_Status_Error;
|
|
|
-- A similar error is to use Ada.Streams.Stream_IO.Stream
|
-- A similar error is to use Ada.Streams.Stream_IO.Stream
|
-- to attempt to perform an operation on a stream file that is
|
-- to attempt to perform an operation on a stream file that is
|
-- not currently open. Status_Error should be raised in this case.
|
-- not currently open. Status_Error should be raised in this case.
|
-- (Defect Report 8652/0046, as reflected in Technical Corrigendum 1.)
|
-- (Defect Report 8652/0046, as reflected in Technical Corrigendum 1.)
|
Check_Status_Error2:
|
Check_Status_Error2:
|
begin
|
begin
|
-- Ensure that the file is not open.
|
-- Ensure that the file is not open.
|
if Ada.Streams.Stream_Io.Is_Open (Stream_File_Object) then
|
if Ada.Streams.Stream_Io.Is_Open (Stream_File_Object) then
|
Ada.Streams.Stream_Io.Close (Stream_File_Object);
|
Ada.Streams.Stream_Io.Close (Stream_File_Object);
|
end if;
|
end if;
|
Stream_Access_Value :=
|
Stream_Access_Value :=
|
Ada.Streams.Stream_Io.Stream (Stream_File_Object);
|
Ada.Streams.Stream_Io.Stream (Stream_File_Object);
|
Report.Failed ("Exception not raised on Stream of closed file");
|
Report.Failed ("Exception not raised on Stream of closed file");
|
exception
|
exception
|
when Ada.Streams.Stream_Io.Status_Error =>
|
when Ada.Streams.Stream_Io.Status_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 2");
|
Report.Failed ("Incorrect exception raised - 2");
|
end Check_Status_Error2;
|
end Check_Status_Error2;
|
|
|
-- Another potentially common error in a file processing environment
|
-- Another potentially common error in a file processing environment
|
-- is to attempt to Open a stream file that is currently open.
|
-- is to attempt to Open a stream file that is currently open.
|
-- Status_Error should be raised in this case.
|
-- Status_Error should be raised in this case.
|
Check_Status_Error3:
|
Check_Status_Error3:
|
begin
|
begin
|
-- Ensure that the file is open.
|
-- Ensure that the file is open.
|
if not Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
if not Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.In_File,
|
Ada.Streams.Stream_IO.In_File,
|
Stream_Filename);
|
Stream_Filename);
|
end if;
|
end if;
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.In_File,
|
Ada.Streams.Stream_IO.In_File,
|
Stream_Filename);
|
Stream_Filename);
|
Report.Failed ("Exception not raised on Open of open file");
|
Report.Failed ("Exception not raised on Open of open file");
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Status_Error =>
|
when Ada.Streams.Stream_IO.Status_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 3");
|
Report.Failed ("Incorrect exception raised - 3");
|
end Check_Status_Error3;
|
end Check_Status_Error3;
|
|
|
-- Another example of a potential error occurring in a file
|
-- Another example of a potential error occurring in a file
|
-- processing environment is to attempt to use the 'Read attribute
|
-- processing environment is to attempt to use the 'Read attribute
|
-- on a stream file that is currently in Out_File or Append_File
|
-- on a stream file that is currently in Out_File or Append_File
|
-- mode. Mode_Error should be raised in both of these cases.
|
-- mode. Mode_Error should be raised in both of these cases.
|
Check_Mode_Error:
|
Check_Mode_Error:
|
declare
|
declare
|
Int_Var : Integer := -10;
|
Int_Var : Integer := -10;
|
begin
|
begin
|
|
|
Reset1:
|
Reset1:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Out_File);
|
Ada.Streams.Stream_IO.Out_File);
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Use_Error =>
|
when Ada.Streams.Stream_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to Out_File not supported for Stream_IO - 1" );
|
( "Reset to Out_File not supported for Stream_IO - 1" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset1;
|
end Reset1;
|
|
|
Stream_Access_Value :=
|
Stream_Access_Value :=
|
Ada.Streams.Stream_IO.Stream (Stream_File_Object);
|
Ada.Streams.Stream_IO.Stream (Stream_File_Object);
|
Integer'Write (Stream_Access_Value, Int_Var);
|
Integer'Write (Stream_Access_Value, Int_Var);
|
|
|
-- File contains an integer value, but is of mode Out_File.
|
-- File contains an integer value, but is of mode Out_File.
|
Integer'Read (Stream_Access_Value, Int_Var);
|
Integer'Read (Stream_Access_Value, Int_Var);
|
Report.Failed ("Exception not raised by 'Read of Out_File");
|
Report.Failed ("Exception not raised by 'Read of Out_File");
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
raise;
|
raise;
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
null;
|
null;
|
Try_Read:
|
Try_Read:
|
begin
|
begin
|
Reset2:
|
Reset2:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Reset
|
Ada.Streams.Stream_IO.Reset
|
(Stream_File_Object, Ada.Streams.Stream_IO.Append_File);
|
(Stream_File_Object, Ada.Streams.Stream_IO.Append_File);
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Use_Error =>
|
when Ada.Streams.Stream_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to Append_File not supported " &
|
( "Reset to Append_File not supported " &
|
"for Stream_IO - 2" );
|
"for Stream_IO - 2" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset2;
|
end Reset2;
|
|
|
Integer'Write (Stream_Access_Value, Int_Var);
|
Integer'Write (Stream_Access_Value, Int_Var);
|
-- Attempt read from Append_File mode file.
|
-- Attempt read from Append_File mode file.
|
Integer'Read (Stream_Access_Value, Int_Var);
|
Integer'Read (Stream_Access_Value, Int_Var);
|
Report.Failed
|
Report.Failed
|
("Exception not raised by 'Read of Append file");
|
("Exception not raised by 'Read of Append file");
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
null;
|
null;
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 4b");
|
Report.Failed ("Incorrect exception raised - 4b");
|
end Try_Read;
|
end Try_Read;
|
|
|
when others => Report.Failed ("Incorrect exception raised - 4a");
|
when others => Report.Failed ("Incorrect exception raised - 4a");
|
end Check_Mode_Error;
|
end Check_Mode_Error;
|
|
|
-- Another example of a this type of potential error is to attempt
|
-- Another example of a this type of potential error is to attempt
|
-- to check for End Of File on a stream file that is currently in
|
-- to check for End Of File on a stream file that is currently in
|
-- Out_File or Append_File mode. Mode_Error should also be raised
|
-- Out_File or Append_File mode. Mode_Error should also be raised
|
-- in both of these cases.
|
-- in both of these cases.
|
Check_End_File:
|
Check_End_File:
|
declare
|
declare
|
Test_Boolean : Boolean := False;
|
Test_Boolean : Boolean := False;
|
begin
|
begin
|
Reset3:
|
Reset3:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Out_File);
|
Ada.Streams.Stream_IO.Out_File);
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Use_Error =>
|
when Ada.Streams.Stream_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to Out_File not supported for Stream_IO - 3" );
|
( "Reset to Out_File not supported for Stream_IO - 3" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset3;
|
end Reset3;
|
|
|
Test_Boolean :=
|
Test_Boolean :=
|
Ada.Streams.Stream_IO.End_Of_File (Stream_File_Object);
|
Ada.Streams.Stream_IO.End_Of_File (Stream_File_Object);
|
Report.Failed ("Exception not raised by EOF on Out_File");
|
Report.Failed ("Exception not raised by EOF on Out_File");
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
null;
|
null;
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
null;
|
null;
|
EOF_For_Append_File:
|
EOF_For_Append_File:
|
begin
|
begin
|
Reset4:
|
Reset4:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Reset
|
Ada.Streams.Stream_IO.Reset
|
(Stream_File_Object, Ada.Streams.Stream_IO.Append_File);
|
(Stream_File_Object, Ada.Streams.Stream_IO.Append_File);
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Use_Error =>
|
when Ada.Streams.Stream_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to Append_File not supported " &
|
( "Reset to Append_File not supported " &
|
"for Stream_IO - 4" );
|
"for Stream_IO - 4" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset4;
|
end Reset4;
|
|
|
Test_Boolean :=
|
Test_Boolean :=
|
Ada.Streams.Stream_IO.End_Of_File (Stream_File_Object);
|
Ada.Streams.Stream_IO.End_Of_File (Stream_File_Object);
|
Report.Failed
|
Report.Failed
|
("Exception not raised by EOF of Append file");
|
("Exception not raised by EOF of Append file");
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
raise;
|
raise;
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 5b");
|
Report.Failed ("Incorrect exception raised - 5b");
|
end EOF_For_Append_File;
|
end EOF_For_Append_File;
|
|
|
when others => Report.Failed ("Incorrect exception raised - 5a");
|
when others => Report.Failed ("Incorrect exception raised - 5a");
|
end Check_End_File;
|
end Check_End_File;
|
|
|
|
|
|
|
-- In a similar situation to the above cases for attribute 'Read,
|
-- In a similar situation to the above cases for attribute 'Read,
|
-- an attempt to use the 'Output attribute on a stream file that
|
-- an attempt to use the 'Output attribute on a stream file that
|
-- is currently in In_File mode should result in Mode_Error being
|
-- is currently in In_File mode should result in Mode_Error being
|
-- raised.
|
-- raised.
|
Check_Output_Mode_Error:
|
Check_Output_Mode_Error:
|
begin
|
begin
|
Reset5:
|
Reset5:
|
begin
|
begin
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.Reset (Stream_File_Object,
|
Ada.Streams.Stream_IO.In_File);
|
Ada.Streams.Stream_IO.In_File);
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Use_Error =>
|
when Ada.Streams.Stream_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to In_File not supported for Stream_IO - 6" );
|
( "Reset to In_File not supported for Stream_IO - 6" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset5;
|
end Reset5;
|
|
|
Stream_Access_Value :=
|
Stream_Access_Value :=
|
Ada.Streams.Stream_IO.Stream (Stream_File_Object);
|
Ada.Streams.Stream_IO.Stream (Stream_File_Object);
|
String'Output (Stream_Access_Value, "User-Oriented String");
|
String'Output (Stream_Access_Value, "User-Oriented String");
|
Report.Failed ("Exception not raised by 'Output to In_File");
|
Report.Failed ("Exception not raised by 'Output to In_File");
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
null;
|
null;
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
when Ada.Streams.Stream_IO.Mode_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 6");
|
Report.Failed ("Incorrect exception raised - 6");
|
end Check_Output_Mode_Error;
|
end Check_Output_Mode_Error;
|
|
|
-- Any case of attempting to Open a stream file with a string for
|
-- Any case of attempting to Open a stream file with a string for
|
-- the parameter Name that does not allow the identification of an
|
-- the parameter Name that does not allow the identification of an
|
-- external file will result in the exception Name_Error being
|
-- external file will result in the exception Name_Error being
|
-- raised.
|
-- raised.
|
Check_Illegal_File_Name:
|
Check_Illegal_File_Name:
|
begin
|
begin
|
if Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
if Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
Ada.Streams.Stream_IO.Close (Stream_File_Object);
|
Ada.Streams.Stream_IO.Close (Stream_File_Object);
|
end if;
|
end if;
|
-- No external file exists with this filename, allowing no
|
-- No external file exists with this filename, allowing no
|
-- association with an internal file object, resulting in the
|
-- association with an internal file object, resulting in the
|
-- raising of the exception Name_Error.
|
-- raising of the exception Name_Error.
|
Ada.Streams.Stream_IO.Open(File => Stream_File_Object,
|
Ada.Streams.Stream_IO.Open(File => Stream_File_Object,
|
Mode => Ada.Streams.Stream_IO.Out_File,
|
Mode => Ada.Streams.Stream_IO.Out_File,
|
Name => Report.Legal_File_Name(2));
|
Name => Report.Legal_File_Name(2));
|
Report.Failed ("Exception not raised by bad filename on Open");
|
Report.Failed ("Exception not raised by bad filename on Open");
|
exception
|
exception
|
when Ada.Streams.Stream_IO.Name_Error =>
|
when Ada.Streams.Stream_IO.Name_Error =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Incorrect exception raised - 7");
|
Report.Failed ("Incorrect exception raised - 7");
|
end Check_Illegal_File_Name;
|
end Check_Illegal_File_Name;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
null;
|
null;
|
when others =>
|
when others =>
|
Report.Failed ("Unexpected exception in Operational Test Block");
|
Report.Failed ("Unexpected exception in Operational Test Block");
|
|
|
end Operational_Test_Block;
|
end Operational_Test_Block;
|
|
|
Deletion:
|
Deletion:
|
begin
|
begin
|
if Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
if Ada.Streams.Stream_IO.Is_Open (Stream_File_Object) then
|
Ada.Streams.Stream_IO.Delete (Stream_File_Object);
|
Ada.Streams.Stream_IO.Delete (Stream_File_Object);
|
else
|
else
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.Open (Stream_File_Object,
|
Ada.Streams.Stream_IO.Out_File,
|
Ada.Streams.Stream_IO.Out_File,
|
Stream_Filename);
|
Stream_Filename);
|
Ada.Streams.Stream_IO.Delete (Stream_File_Object);
|
Ada.Streams.Stream_IO.Delete (Stream_File_Object);
|
end if;
|
end if;
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed
|
Report.Failed
|
( "Delete not properly implemented for Stream_IO" );
|
( "Delete not properly implemented for Stream_IO" );
|
end Deletion;
|
end Deletion;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
Report.Result;
|
Report.Result;
|
when others =>
|
when others =>
|
Report.Failed ( "Unexpected exception" );
|
Report.Failed ( "Unexpected exception" );
|
Report.Result;
|
Report.Result;
|
|
|
end CXAC003;
|
end CXAC003;
|
|
|