Dataset Preview
Full Screen Viewer
Full Screen
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code: DatasetGenerationError Exception: ArrowInvalid Message: Failed to parse value: notfound Traceback: Traceback (most recent call last): File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single writer.write_table(table) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table pa_table = table_cast(pa_table, self._schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast return cast_table_to_schema(table, schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in cast_table_to_schema arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()] File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in <listcomp> arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()] File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in wrapper return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks]) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in <listcomp> return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks]) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2116, in cast_array_to_feature return array_cast( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1804, in wrapper return func(array, *args, **kwargs) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1963, in array_cast return array.cast(pa_type) File "pyarrow/array.pxi", line 996, in pyarrow.lib.Array.cast File "/src/services/worker/.venv/lib/python3.9/site-packages/pyarrow/compute.py", line 404, in cast return call_function("cast", [arr], options, memory_pool) File "pyarrow/_compute.pyx", line 590, in pyarrow._compute.call_function File "pyarrow/_compute.pyx", line 385, in pyarrow._compute.Function.call File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status pyarrow.lib.ArrowInvalid: Failed to parse value: notfound The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1529, in compute_config_parquet_and_info_response parquet_operations = convert_to_parquet(builder) File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1154, in convert_to_parquet builder.download_and_prepare( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare self._download_and_prepare( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare self._prepare_split(split_generator, **prepare_split_kwargs) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split for job_id, done, content in self._prepare_split_single( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2038, in _prepare_split_single raise DatasetGenerationError("An error occurred while generating the dataset") from e datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
size
int64 | ext
string | lang
string | max_stars_repo_licenses
sequence | max_stars_count
float64 | content
string | avg_line_length
float64 | max_line_length
int64 | alphanum_fraction
float64 | low_alphanum
bool | long_lines
bool | lexable
bool |
---|---|---|---|---|---|---|---|---|---|---|---|
5,992 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C34004C.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- FOR DERIVED FIXED POINT TYPES:
-- CHECK THAT ALL VALUES OF THE PARENT (BASE) TYPE ARE PRESENT FOR
-- THE DERIVED (BASE) TYPE WHEN THE DERIVED TYPE DEFINITION IS
-- CONSTRAINED.
-- CHECK THAT ANY CONSTRAINT IMPOSED ON THE PARENT SUBTYPE IS ALSO
-- IMPOSED ON THE DERIVED SUBTYPE.
-- HISTORY:
-- JRK 09/08/86
-- JLH 09/25/87 REFORMATTED HEADER.
-- JRL 03/13/92 MODIFIED TO DEFEAT OPTIMIZATION WHEN ATTEMPTING TO
-- RAISE CONSTRAINT_ERROR.
-- JRL 03/30/93 REMOVED NUMERIC_ERROR FROM TEST.
-- DTN 11/30/95 REMOVED NON ADA95 ATTRIBUTES.
WITH SYSTEM; USE SYSTEM;
WITH REPORT; USE REPORT;
PROCEDURE C34004C IS
TYPE PARENT IS DELTA 0.01 RANGE -100.0 .. 100.0;
TYPE T IS NEW PARENT DELTA 0.1 RANGE
IDENT_INT (1) * (-30.0) ..
IDENT_INT (1) * ( 30.0);
SUBTYPE SUBPARENT IS PARENT DELTA 0.1 RANGE -30.0 .. 30.0;
TYPE S IS NEW SUBPARENT;
X,XA : T;
Y,YA : S;
FUNCTION OUT_OF_BOUNDS ( VAR1 , VAR2 : T ) RETURN BOOLEAN IS
BEGIN
IF ( VAR1 + VAR2 ) IN T THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN TRUE ;
END OUT_OF_BOUNDS ;
FUNCTION OUT_OF_BOUNDS ( VAR1 , VAR2 : S ) RETURN BOOLEAN IS
BEGIN
IF ( VAR1 + VAR2 ) IN S THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN TRUE ;
END OUT_OF_BOUNDS ;
BEGIN
TEST ("C34004C", "CHECK THAT ALL VALUES OF THE PARENT (BASE) " &
"TYPE ARE PRESENT FOR THE DERIVED (BASE) TYPE " &
"WHEN THE DERIVED TYPE DEFINITION IS " &
"CONSTRAINED. ALSO CHECK THAT ANY CONSTRAINT " &
"IMPOSED ON THE PARENT SUBTYPE IS ALSO IMPOSED " &
"ON THE DERIVED SUBTYPE. CHECK FOR DERIVED " &
"FIXED POINT TYPES");
-- CHECK THAT BASE TYPE VALUES NOT IN THE SUBTYPE ARE PRESENT.
DECLARE
TBD : CONSTANT := BOOLEAN'POS (T'BASE'DELTA <= 0.01);
SBD : CONSTANT := BOOLEAN'POS (S'BASE'DELTA <= 0.01);
BEGIN
IF TBD = 0 OR SBD = 0 THEN
FAILED ("INCORRECT 'BASE'DELTA");
END IF;
END;
DECLARE
N : INTEGER := IDENT_INT (8);
BEGIN
IF 98.0 + T'(1.0) + N * 0.0078125 /= 99.0625 OR
98.0 + S'(1.0) + 8 * 0.0078125 /= 99.0625 OR
-98.0 - T'(1.0) - N * 0.0078125 /= -99.0625 OR
-98.0 - S'(1.0) - 8 * 0.0078125 /= -99.0625 THEN
FAILED ("INCORRECT + OR -");
END IF;
END;
IF T'FIRST /= -30.0 OR T'LAST /= 30.0 OR
S'FIRST /= -30.0 OR S'LAST /= 30.0 THEN
FAILED ("INCORRECT 'FIRST OR 'LAST");
END IF;
BEGIN
X := -30.0;
Y := -30.0;
IF PARENT (X) /= PARENT (Y) THEN -- USE X AND Y.
FAILED ("INCORRECT CONVERSION TO PARENT - 1");
END IF;
X := 30.0;
Y := 30.0;
IF PARENT (X) /= PARENT (Y) THEN -- USE X AND Y.
FAILED ("INCORRECT CONVERSION TO PARENT - 2");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED BY OK ASSIGNMENT");
END;
BEGIN
X := -30.0 ;
XA := -0.0625 ;
IF NOT OUT_OF_BOUNDS ( X , XA ) THEN
FAILED ( "CONSTRAINT_ERROR NOT RAISED -- X := -30.0625" ) ;
END IF ;
EXCEPTION
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- X := -30.0625");
END;
BEGIN
X := 30.0 ;
XA := 0.0625 ;
IF NOT OUT_OF_BOUNDS ( X , XA ) THEN
FAILED ( "CONSTRAINT_ERROR NOT RAISED -- X := 30.0625" ) ;
END IF ;
EXCEPTION
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- X := 30.0625");
END;
BEGIN
Y := -30.0 ;
YA := -0.0625 ;
IF NOT OUT_OF_BOUNDS ( Y , YA ) THEN
FAILED ( "CONSTRAINT_ERROR NOT RAISED -- Y := -30.0625" ) ;
END IF ;
EXCEPTION
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- Y := -30.0625");
END;
BEGIN
Y := 30.0 ;
YA := 0.0625 ;
IF NOT OUT_OF_BOUNDS ( Y , YA ) THEN
FAILED ( "CONSTRAINT_ERROR NOT RAISED -- Y := 30.0625" ) ;
END IF ;
EXCEPTION
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- Y := 30.0625");
END;
RESULT;
END C34004C;
| 31.208333 | 79 | 0.534713 | false | false | true |
4,706 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C74305A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A DEFERRED CONSTANT CAN BE USED AS A DEFAULT
-- INITIALIZATION FOR A PARAMETER OR AS A DEFAULT INITIA-
-- LIZATION FOR A COMPONENT (NON GENERIC CASE).
-- DAT 4/06/81
-- RM 5/21/81
-- SPS 8/23/82
-- SPS 2/10/83
-- SPS 10/20/83
-- EG 12/20/83
-- GJD 11/15/95 REMOVED ADA 95 INCOMPATIBILITY.
WITH REPORT;
PROCEDURE C74305A IS
USE REPORT;
PACKAGE PK IS
TYPE T1 IS PRIVATE;
TYPE T2 IS PRIVATE;
C1 : CONSTANT T1; -- OK.
PROCEDURE P1 (P : T1 := C1); -- OK.
TYPE R1 IS RECORD
C : T1 := C1; -- OK.
END RECORD;
PRIVATE
PROCEDURE PROC2 (P : T1 := C1); -- OK.
TYPE R2 IS RECORD
C : T1 := C1; -- OK.
D : INTEGER := C1'SIZE; -- OK.
END RECORD;
FUNCTION F1 (P : T1) RETURN T1;
TYPE T1 IS NEW INTEGER;
TYPE T2 IS ARRAY (1..2) OF INTEGER; -- OK.
FUNCTION F2 (P : T1) RETURN T1;
PROCEDURE P3 (P : T1 := C1+1); -- OK.
PROCEDURE P4 (P : T1 := F1(C1));
TYPE R5 IS RECORD
C : T1 := F2(C1);
END RECORD;
PROCEDURE P5 (P : T1 := C1+2) RENAMES P3;
TYPE R3 IS RECORD
C : T1 := C1; -- OK.
END RECORD;
C1 : CONSTANT T1 := 1; -- OK.
C2 : CONSTANT T2 := (1,1); -- OK.
END PK;
USE PK;
PACKAGE BODY PK IS
R11 : R1;
PROCEDURE P1 (P : T1 := C1) IS
BEGIN
IF ( P /= 1 ) THEN
FAILED ("PARAMETER DEFAULT OF P1 NOT PROPERLY " &
"INITIALIZED");
END IF;
END P1;
PROCEDURE PROC2 (P : T1 := C1) IS
BEGIN NULL; END PROC2;
PROCEDURE P3 (P : T1 := C1+1) IS
BEGIN
IF ( P /= 3 ) THEN
FAILED ("PARAMETER DEFAULT OF P5 NOT PROPERLY " &
"INITIALIZED");
END IF;
END P3;
FUNCTION F1 (P : T1) RETURN T1 IS
BEGIN
RETURN P+10;
END F1;
PROCEDURE P4 (P : T1 := F1(C1)) IS
BEGIN
IF ( P /= 11 ) THEN
FAILED ("WRONG ACTUAL PARAMETER RECEIVED");
END IF;
END P4;
FUNCTION F2 (P : T1) RETURN T1 IS
BEGIN
RETURN P+20;
END F2;
BEGIN -- PK BODY.
DECLARE
R55 : R5;
BEGIN
TEST ("C74305A","CHECK THAT A DEFERRED CONSTANT CAN " &
"BE USED AS A DEFAULT INITIALIZATION " &
"FOR A PARAMETER OR AS A DEFAULT " &
"INITIALIZATION FOR A COMPONENT (NON " &
"GENERIC CASE)");
IF ( R11.C /= 1 ) THEN
FAILED ("RECORD R11 NOT PROPERLY INITIALIZED");
END IF;
P4;
IF ( R55.C /= 21 ) THEN
FAILED ("RECORD R55 NOT PROPERLY INITIALIZED");
END IF;
P5;
END;
END PK;
BEGIN
P1;
RESULT;
END C74305A;
| 29.229814 | 79 | 0.474076 | false | false | true |
4,900 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CE3403F.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT SKIP_LINE RAISES END_ERROR IF AN ATTEMPT IS
-- MADE TO SKIP A FILE TERMINATOR.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH
-- SUPPORT TEXT FILES.
-- HISTORY:
-- ABW 08/26/82
-- SPS 11/11/82
-- SPS 12/14/82
-- TBN 11/04/86 REVISED TEST TO OUTPUT A NON_APPLICABLE
-- RESULT WHEN FILES ARE NOT SUPPORTED.
-- DWC 09/09/87 REVISED TEST TO USE A FILE NAME, REMOVED
-- DEPENDENCE ON RESET, AND ADDED ATTEMPT TO
-- DELETE THE FILE.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3403F IS
INCOMPLETE : EXCEPTION;
FILE : FILE_TYPE;
CHAR : CHARACTER := ('C');
ONE : POSITIVE_COUNT := POSITIVE_COUNT(IDENT_INT (1));
TWO : POSITIVE_COUNT := POSITIVE_COUNT(IDENT_INT (2));
BEGIN
TEST ("CE3403F" , "CHECK THAT SKIP_LINE RAISES END_ERROR " &
"IF AN ATTEMPT IS MADE TO SKIP A FILE " &
"TERMINATOR");
BEGIN
CREATE (FILE, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED; TEXT CREATE");
RAISE INCOMPLETE;
END;
FOR I IN 1..3
LOOP
PUT (FILE,CHAR);
END LOOP;
CLOSE (FILE);
BEGIN
OPEN (FILE, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT OPEN " &
"FOR IN_FILE MODE");
RAISE INCOMPLETE;
END;
BEGIN
GET (FILE, CHAR);
IF CHAR /= 'C' THEN
FAILED ("INCORRECT VALUE READ");
END IF;
SKIP_LINE (FILE);
SKIP_LINE (FILE);
FAILED ("END_ERROR NOT RAISED - 1");
EXCEPTION
WHEN END_ERROR =>
IF COL (FILE) /= ONE THEN
FAILED ("COL NOT RESET CORRECTLY");
END IF;
IF NOT END_OF_FILE (FILE) THEN
FAILED ("NOT POSITIONED AT END OF FILE");
END IF;
IF PAGE (FILE) /= TWO THEN
FAILED ("PAGE NOT INCREMENTED");
END IF;
IF LINE (FILE) /= ONE THEN
FAILED ("LINE NOT RESET CORRECTLY");
END IF;
IF NOT END_OF_LINE (FILE) THEN
FAILED ("EOL FALSE AT FILE TERMINATOR");
END IF;
IF NOT END_OF_PAGE (FILE) THEN
FAILED ("EOP FALSE AT FILE TERMINATOR");
END IF;
BEGIN
SKIP_LINE (FILE);
FAILED ("END_ERROR NOT RAISED - 2");
EXCEPTION
WHEN END_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 1");
END;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 2");
END;
BEGIN
DELETE (FILE);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
RESULT;
EXCEPTION
WHEN INCOMPLETE =>
RESULT;
END CE3403F;
| 31.210191 | 79 | 0.536531 | false | false | true |
1,865 | ada | Ada | [
"Info-ZIP"
] | 1 | with ada.text_io;
use ada.text_io;
procedure fast_fibo is
-- We work with biggest natural integers in a 64 bits machine
type Big_Int is mod 2**64;
-- We provide an index type for accessing the fibonacci sequence terms
type Index is new Big_Int;
-- fibo is a generic function that needs a modulus type since it will return
-- the n'th term of the fibonacci sequence modulus this type (use Big_Int to get the
-- expected behaviour in this particular task)
generic
type ring_element is mod <>;
with function "*" (a, b : ring_element) return ring_element is <>;
function fibo (n : Index) return ring_element;
function fibo (n : Index) return ring_element is
type matrix is array (1 .. 2, 1 .. 2) of ring_element;
-- f is the matrix you apply to a column containing (F_n, F_{n+1}) to get
-- the next one containing (F_{n+1},F_{n+2})
-- could be a more general matrix (given as a generic parameter) to deal with
-- other linear sequences of order 2
f : constant matrix := (1 => (0, 1), 2 => (1, 1));
function "*" (a, b : matrix) return matrix is
(1 => (a(1,1)*b(1,1)+a(1,2)*b(2,1), a(1,1)*b(1,2)+a(1,2)*b(2,2)),
2 => (a(2,1)*b(1,1)+a(2,2)*b(2,1), a(2,1)*b(1,2)+a(2,2)*b(2,2)));
function square (m : matrix) return matrix is (m * m);
-- Fast_Pow could be non recursive but it doesn't really matter since
-- the number of calls is bounded up by the size (in bits) of Big_Int (e.g 64)
function fast_pow (m : matrix; n : Index) return matrix is
(if n = 0 then (1 => (1, 0), 2 => (0, 1)) -- = identity matrix
elsif n mod 2 = 0 then square (fast_pow (m, n / 2))
else m * square (fast_pow (m, n / 2)));
begin
return fast_pow (f, n)(2, 1);
end fibo;
function Big_Int_Fibo is new fibo (Big_Int);
begin
-- calculate instantly F_n with n=10^15 (modulus 2^64 )
put_line (Big_Int_Fibo (10**15)'img);
end fast_fibo;
| 37.3 | 86 | 0.657373 | false | false | true |
3,682 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CE3901A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT GET AND PUT FOR ENUMERATED TYPES RAISE STATUS ERROR
-- IF THE FILE IS NOT OPEN.
-- HISTORY:
-- SPS 10/07/82
-- JBG 02/22/84 CHANGED TO .ADA TEST
-- DWC 09/16/87 ADDED AN ATTEMPT TO CREATE A FILE AND THEN
-- RETESTED OBJECTIVE.
-- BCB 10/03/90 ADDED NAME_ERROR AS A CHOICE TO THE EXCEPTION
-- HANDLER FOR CREATE.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3901A IS
BEGIN
TEST ("CE3901A", "CHECK THAT GET AND PUT FOR ENUMERATED TYPES " &
"RAISE STATUS ERROR IF THE FILE IS NOT OPEN.");
DECLARE
TYPE COLOR IS (RED, BLUE, GREEN, ORANGE, YELLOW);
FT : FILE_TYPE;
PACKAGE COLOR_IO IS NEW ENUMERATION_IO (COLOR);
USE COLOR_IO;
X : COLOR;
BEGIN
BEGIN
PUT (FT, RED);
FAILED ("STATUS_ERROR NOT RAISED - PUT - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - PUT - 1");
END;
BEGIN
GET (FT, X);
FAILED ("STATUS_ERROR NOT RAISED - GET - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - GET - 1");
END;
BEGIN
CREATE (FT, OUT_FILE, LEGAL_FILE_NAME); -- THIS IS JUST
CLOSE (FT); -- AN ATTEMPT TO CREATE A
EXCEPTION -- FILE. OBJECTIVE IS MET
WHEN USE_ERROR -- EITHER WAY.
| NAME_ERROR => NULL;
END;
BEGIN
PUT (FT, RED);
FAILED ("STATUS_ERROR NOT RAISED - PUT - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - PUT - 2");
END;
BEGIN
GET (FT, X);
FAILED ("STATUS_ERROR NOT RAISED - GET - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - GET - 2");
END;
END;
RESULT;
END CE3901A;
| 34.411215 | 79 | 0.535035 | false | false | true |
1,898 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure RungeKutta is
type Floaty is digits 15;
type Floaty_Array is array (Natural range <>) of Floaty;
package FIO is new Ada.Text_IO.Float_IO(Floaty); use FIO;
type Derivative is access function(t, y : Floaty) return Floaty;
package Math is new Ada.Numerics.Generic_Elementary_Functions (Floaty);
function calc_err (t, calc : Floaty) return Floaty;
procedure Runge (yp_func : Derivative; t, y : in out Floaty_Array;
dt : Floaty) is
dy1, dy2, dy3, dy4 : Floaty;
begin
for n in t'First .. t'Last-1 loop
dy1 := dt * yp_func(t(n), y(n));
dy2 := dt * yp_func(t(n) + dt / 2.0, y(n) + dy1 / 2.0);
dy3 := dt * yp_func(t(n) + dt / 2.0, y(n) + dy2 / 2.0);
dy4 := dt * yp_func(t(n) + dt, y(n) + dy3);
t(n+1) := t(n) + dt;
y(n+1) := y(n) + (dy1 + 2.0 * (dy2 + dy3) + dy4) / 6.0;
end loop;
end Runge;
procedure Print (t, y : Floaty_Array; modnum : Positive) is begin
for i in t'Range loop
if i mod modnum = 0 then
Put("y("); Put (t(i), Exp=>0, Fore=>0, Aft=>1);
Put(") = "); Put (y(i), Exp=>0, Fore=>0, Aft=>8);
Put(" Error:"); Put (calc_err(t(i),y(i)), Aft=>5);
New_Line;
end if;
end loop;
end Print;
function yprime (t, y : Floaty) return Floaty is begin
return t * Math.Sqrt (y);
end yprime;
function calc_err (t, calc : Floaty) return Floaty is
actual : constant Floaty := (t**2 + 4.0)**2 / 16.0;
begin return abs(actual-calc);
end calc_err;
dt : constant Floaty := 0.10;
N : constant Positive := 100;
t_arr, y_arr : Floaty_Array(0 .. N);
begin
t_arr(0) := 0.0;
y_arr(0) := 1.0;
Runge (yprime'Access, t_arr, y_arr, dt);
Print (t_arr, y_arr, 10);
end RungeKutta;
| 35.811321 | 74 | 0.567439 | false | false | true |
3,197 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CD1C04D.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT AN ENUMERATION REPRESENTATION CLAUSE CAN BE GIVEN
-- FOR A DERIVED ENUMERATION TYPE EVEN IF THE REPRESENTATION IS
-- INHERITED FROM THE PARENT, AND THAT THE CLAUSE FOR THE DERIVED
-- TYPE OVERRIDES THAT OF THE PARENT.
-- HISTORY:
-- JET 09/21/87 CREATED ORIGINAL TEST.
-- DHH 03/29/89 CHANGE FROM 'A' TEST TO 'C' TEST AND FROM '.DEP'
-- '.ADA'. ADDED CHECK ON REPRESENTATION CLAUSE.
WITH REPORT; USE REPORT;
WITH ENUM_CHECK; -- CONTAINS A CALL TO 'FAILED'.
PROCEDURE CD1C04D IS
TYPE NORMAL_TYPE IS (RED, BLUE, GREEN, YELLOW);
TYPE PARENT_TYPE IS (RED, BLUE, GREEN, YELLOW);
FOR PARENT_TYPE USE
(RED => 256, BLUE => 257, GREEN => 258, YELLOW => 259);
TYPE DERIVED_TYPE IS NEW PARENT_TYPE;
FOR DERIVED_TYPE USE
(RED => 16, BLUE => 17, GREEN => 18, YELLOW => 19);
TYPE INT1 IS RANGE 16 .. 19;
FOR INT1'SIZE USE DERIVED_TYPE'SIZE;
PROCEDURE CHECK_1 IS NEW ENUM_CHECK(DERIVED_TYPE, INT1);
BEGIN
TEST("CD1C04D", "CHECK THAT AN ENUMERATION REPRESENTATION " &
"CLAUSE CAN BE GIVEN FOR A DERIVED ENUMERATION " &
"TYPE EVEN IF THE REPRESENTATION IS INHERITED " &
"FROM THE PARENT, AND THAT THE CLAUSE FOR THE " &
"DERIVED TYPE OVERRIDES THAT OF THE PARENT");
IF PARENT_TYPE'SIZE = IDENT_INT (NORMAL_TYPE'SIZE) THEN
COMMENT ("PARENT_TYPE'SIZE WAS NOT AFFECTED BY THE " &
"REPRESENTATION CLAUSE");
END IF;
IF DERIVED_TYPE'SIZE >= IDENT_INT (PARENT_TYPE'SIZE) THEN
COMMENT ("THE SPECIFICATION OF SMALLER VALUES FOR THE " &
"REPRESENTATION OF DERIVED_TYPE DID NOT " &
"REDUCE THE SIZE OF DERIVED_TYPE");
END IF;
CHECK_1 (DERIVED_TYPE'(GREEN), 18, "DERIVED_TYPE");
RESULT;
END CD1C04D;
| 39.469136 | 79 | 0.636534 | false | false | true |
1,266 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Non_Continuous is
type Sequence is array (Positive range <>) of Integer;
procedure Put_NCS
( Tail : Sequence; -- To generate subsequences of
Head : Sequence := (1..0 => 1); -- Already generated
Contiguous : Boolean := True -- It is still continuous
) is
begin
if not Contiguous and then Head'Length > 1 then
for I in Head'Range loop
Put (Integer'Image (Head (I)));
end loop;
New_Line;
end if;
if Tail'Length /= 0 then
declare
New_Head : Sequence (Head'First..Head'Last + 1);
begin
New_Head (Head'Range) := Head;
for I in Tail'Range loop
New_Head (New_Head'Last) := Tail (I);
Put_NCS
( Tail => Tail (I + 1..Tail'Last),
Head => New_Head,
Contiguous => Contiguous and then (I = Tail'First or else Head'Length = 0)
);
end loop;
end;
end if;
end Put_NCS;
begin
Put_NCS ((1,2,3)); New_Line;
Put_NCS ((1,2,3,4)); New_Line;
Put_NCS ((1,2,3,4,5)); New_Line;
end Test_Non_Continuous;
| 33.315789 | 92 | 0.515008 | false | false | true |
1,829 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Strings.Unbounded;
private with Ada.Containers.Indefinite_Vectors;
generic
with procedure Print_Line(Indention: Natural; Line: String);
package S_Expr is
function "-"(S: String) return Ada.Strings.Unbounded.Unbounded_String
renames Ada.Strings.Unbounded.To_Unbounded_String;
function "+"(U: Ada.Strings.Unbounded.Unbounded_String) return String
renames Ada.Strings.Unbounded.To_String;
type Empty_Data is tagged null record;
subtype Data is Empty_Data'Class;
procedure Print(This: Empty_Data; Indention: Natural);
-- any object form class Data knows how to print itself
-- objects of class data are either List of Data or Atomic
-- atomic objects hold either an integer or a float or a string
type List_Of_Data is new Empty_Data with private;
overriding procedure Print(This: List_Of_Data; Indention: Natural);
function First(This: List_Of_Data) return Data;
function Rest(This: List_Of_Data) return List_Of_Data;
function Empty(This: List_Of_Data) return Boolean;
type Atomic is new Empty_Data with null record;
type Str_Data is new Atomic with record
Value: Ada.Strings.Unbounded.Unbounded_String;
Quoted: Boolean := False;
end record;
overriding procedure Print(This: Str_Data; Indention: Natural);
type Int_Data is new Atomic with record
Value: Integer;
end record;
overriding procedure Print(This: Int_Data; Indention: Natural);
type Flt_Data is new Atomic with record
Value: Float;
end record;
overriding procedure Print(This: Flt_Data; Indention: Natural);
private
package Vectors is new Ada.Containers.Indefinite_Vectors
(Index_Type => Positive,
Element_Type => Data);
type List_Of_Data is new Empty_Data with record
Values: Vectors.Vector;
end record;
end S_Expr;
| 32.660714 | 72 | 0.745763 | false | false | true |
335 | ada | Ada | [
"Info-ZIP"
] | 1 | task body Some_Task is
begin
loop
select
-- Some alternatives
...
or accept Stop do
-- Some cleanup while holding the caller is here
end Stop;
-- A cleanup asynchronous to the caller is here
exit; -- We are through
end select
end loop;
end Some_Task;
| 22.333333 | 60 | 0.567164 | false | false | true |
3,010 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C45613A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS RAISED
-- BY "**" FOR INTEGERS WHEN THE RESULT EXCEEDS THE RANGE
-- OF THE BASE TYPE.
-- *** NOTE: This test has been modified since ACVC version 1.11 to -- 9X
-- *** remove incompatibilities associated with the transition -- 9X
-- *** to Ada 9X. -- 9X
-- *** -- 9X
-- H. TILTON 10/06/86
-- MRM 03/30/93 REMOVED NUMERIC_ERROR FOR 9X COMPATIBILITY
WITH REPORT; USE REPORT;
PROCEDURE C45613A IS
BEGIN
TEST ("C45613A","CHECK THAT CONSTRAINT_ERROR " &
"IS RAISED BY ""**"" FOR INTEGERS WHEN THE " &
"RESULT EXCEEDS THE RANGE OF THE BASE TYPE");
DECLARE
INT : INTEGER;
BEGIN
INT := IDENT_INT(INTEGER'LAST ** IDENT_INT(2));
FAILED ("NO EXCEPTION FOR SECOND POWER OF INTEGER'LAST");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR " &
"SECOND POWER OF " &
"INTEGER'LAST");
END;
DECLARE
INT : INTEGER;
BEGIN
INT := IDENT_INT(INTEGER'FIRST ** IDENT_INT(3));
FAILED ("NO EXCEPTION FOR THIRD POWER OF INTEGER'FIRST");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR " &
"THIRD POWER OF " &
"INTEGER'FIRST");
END;
RESULT;
END C45613A;
| 37.625 | 79 | 0.553488 | false | false | true |
47 | ada | Ada | [
"Info-ZIP"
] | 1 | Put_Line ("Mary had a " & New_Str & " lamb.");
| 23.5 | 46 | 0.574468 | false | false | true |
852 | ada | Ada | [
"BSD-4-Clause",
"BSD-3-Clause"
] | 3 | -- gen_.ada
with TEXT_IO;
use TEXT_IO;
generic
MAX_STRING_LENGTH: in POSITIVE;
package DYNAMIC_STRING is
subtype STRING_LENGTHS is INTEGER range 0 .. MAX_STRING_LENGTH;
subtype STRING_INDICES is STRING_LENGTHS;
type DYNAMIC_STRINGS(LENGTH: STRING_LENGTHS := 0) is private;
function LENGTH (PASCAL_STRING: DYNAMIC_STRINGS) return STRING_INDICES;
private
type DYNAMIC_STRINGS(LENGTH: STRING_LENGTHS := 0) is record
STRING_ARRAY: STRING (1 .. LENGTH);
end record;
end DYNAMIC_STRING;
package body DYNAMIC_STRING is
function LENGTH (PASCAL_STRING: DYNAMIC_STRINGS) return STRING_INDICES is
begin
return PASCAL_STRING.LENGTH;
end;
end DYNAMIC_STRING;
with DYNAMIC_STRING;
package STRING_80 is new DYNAMIC_STRING(MAX_STRING_LENGTH => 80);
with string_80;
procedure foo is
s : string_80.dynamic_strings;
begin
null;
end;
| 24.342857 | 75 | 0.785211 | false | false | true |
706 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
procedure Quadratic_Equation is
type Roots is array (1..2) of Float;
function Solve (A, B, C : Float) return Roots is
SD : constant Float := sqrt (B**2 - 4.0 * A * C);
X : Float;
begin
if B < 0.0 then
X := (- B + SD) / 2.0 * A;
return (X, C / (A * X));
else
X := (- B - SD) / 2.0 * A;
return (C / (A * X), X);
end if;
end Solve;
R : constant Roots := Solve (1.0, -10.0E5, 1.0);
begin
Put_Line ("X1 =" & Float'Image (R (1)) & " X2 =" & Float'Image (R (2)));
end Quadratic_Equation;
| 30.695652 | 79 | 0.524079 | false | false | true |
4,519 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CE3411C.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT COL OPERATES ON THE CURRENT DEFAULT OUTPUT FILE WHEN
-- NO FILE IS SPECIFIED. CHECK THAT COL CAN OPERATE ON FILES OF
-- MODES IN_FILE AND OUT_FILE, INCLUDING THE CURRENT DEFAULT
-- INPUT_FILE.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- TEXT FILES.
-- HISTORY:
-- SPS 09/29/82
-- JBG 01/31/83
-- JBG 08/30/83
-- JLH 09/02/87 REMOVED DEPENDENCE ON RESET, REMOVED UNNECESSARY
-- CODE, AND CHECKED FOR USE_ERROR ON DELETE.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3411C IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3411C", "CHECK THAT COL OPERATES ON DEFAULT IN_FILE AND "&
"OUT_FILE FILES");
DECLARE
F1, F2 : FILE_TYPE;
C : POSITIVE_COUNT;
X : CHARACTER;
BEGIN
IF COL /= COL (STANDARD_OUTPUT) THEN
FAILED ("COL DEFAULT NOT STANDARD_OUTPUT");
END IF;
IF COL /= COL (STANDARD_INPUT) THEN
FAILED ("COL DEFAULT NOT STANDARD_INPUT");
END IF;
IF COL /= COL (CURRENT_INPUT) THEN
FAILED ("COL DEFAULT NOT CURRENT_INPUT");
END IF;
IF COL /= COL (CURRENT_OUTPUT) THEN
FAILED ("COL DEFAULT NOT CURRENT_OUTPUT");
END IF;
BEGIN
CREATE (F1, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON CREATE WITH " &
"OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED ON CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
END;
CREATE (F2, OUT_FILE);
SET_OUTPUT (F2);
PUT (F1, "STRING");
IF COL (F1) /= 7 THEN
FAILED ("COL INCORRECT SUBTEST 1");
END IF;
PUT (F2, "OUTPUT STRING");
IF COL /= COL(F2) AND COL(F2) /= 14 THEN
FAILED ("COL INCORRECT SUBTEST 2; WAS " &
COUNT'IMAGE(COL) & " VS. " &
COUNT'IMAGE(COL(F2)));
END IF;
CLOSE (F1);
BEGIN
OPEN (F1, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON TEXT OPEN " &
"WITH IN_FILE MODE");
RAISE INCOMPLETE;
END;
SET_INPUT (F1);
GET (F1, X);
GET (F1, X);
GET (F1, X);
IF X /= 'R' THEN
FAILED ("INCORRECT VALUE READ");
END IF;
IF COL (CURRENT_INPUT) /= 4 AND COL /= 4 THEN
FAILED ("COL INCORRECT SUBTEST 3");
END IF;
BEGIN
DELETE (F1);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
CLOSE (F2);
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3411C;
| 30.741497 | 79 | 0.53773 | false | false | true |
2,784 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C87B06A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT OVERLOADING RESOLUTION USES THE RULE THAT:
--
-- FOR EACH INTEGER TYPE, THERE EXISTS AN IMPLICIT CONVERSION THAT
-- CONVERTS A UNIVERSAL INTEGER VALUE INTO THE CORRESPONDING VALUE
-- OF THE INTEGER TYPE. THIS TEST USES LITERALS AS UNIVERSAL INTEGER
-- VALUES.
-- HISTORY:
-- TRH 08/11/82 CREATED ORIGINAL TEST.
-- DHH 10/20/87 SHORTENED LINES CONTAINING MORE THAN 72 CHARACTERS.
WITH REPORT; USE REPORT;
PROCEDURE C87B06A IS
TYPE MINOR IS NEW INTEGER RANGE 0 .. 17;
TYPE FIXED IS NEW DURATION;
TYPE REAL IS NEW FLOAT;
ERR : BOOLEAN := FALSE;
PROCEDURE P (X : BOOLEAN) IS
BEGIN
ERR := TRUE;
END P;
PROCEDURE P (X : FIXED) IS
BEGIN
ERR := TRUE;
END P;
PROCEDURE P (X : REAL) IS
BEGIN
ERR := TRUE;
END P;
PROCEDURE P (X : FLOAT) IS
BEGIN
ERR := TRUE;
END P;
PROCEDURE P (X : STRING) IS
BEGIN
ERR := TRUE;
END P;
PROCEDURE P (X : MINOR) IS
BEGIN
NULL;
END P;
BEGIN
TEST("C87B06A","OVERLOADING RESOLUTION WITH IMPLICIT CONVERSION " &
"OF UNIVERSAL INTEGER VALUES TO INTEGER VALUES. " &
"CONVERSIONS TO INTEGER VALUES EXISTS FOR ANY INTEGER TYPE");
P (2);
P (2 * 2 + 2);
IF ERR THEN
FAILED("INCORRECT IMPLICIT CONVERSION FROM UNIVERSAL " &
" INTEGER VALUES TO INTEGER TYPE VALUES");
END IF;
RESULT;
END C87B06A;
| 30.593407 | 79 | 0.627874 | false | false | true |
662 | ada | Ada | [
"Zed",
"X11",
"MIT"
] | 2 | No-one has translated the suisnail example into Ada yet. Be the first to create
suisnail in Ada and get one free Internet! If you're the author of the Ada
binding, this is a great way to get people to use 0MQ in Ada.
To submit a new translation email it to zeromq-dev@lists.zeromq.org. Please:
* Stick to identical functionality and naming used in examples so that readers
can easily compare languages.
* You MUST place your name as author in the examples so readers can contact you.
* You MUST state in the email that you license your code under the MIT/X11
license.
Subscribe to the email list at http://lists.zeromq.org/mailman/listinfo/zeromq-dev.
| 47.285714 | 83 | 0.776435 | false | false | false |
2,298 | ada | Ada | [
"Info-ZIP"
] | 1 | package body Generic_Inverted_Index is
-- uses some of the new Ada 2012 syntax
use Source_Vecs;
procedure Store(Storage: in out Storage_Type;
Source: Source_Type;
Item: Item_Type) is
use type Maps.Cursor;
begin
if (Storage.Find(Item) = Maps.No_Element) then
Storage.Insert(Key => Item,
New_Item => Empty_Vector & Source);
else
declare
The_Vector: Vector := Storage.Element(Item);
begin
if The_Vector.Last_Element /= Source then
Storage.Replace
(Key => Item,
New_Item => Storage.Element(Item) & Source);
end if;
end;
end if;
end Store;
function Find(Storage: Storage_Type; Item: Item_Type)
return Vector is
begin
return Storage.Element(Item);
exception
when Constraint_Error => return Empty_Vector; -- found nothing
end Find;
function Is_In(S: Source_Type; V: Vector) return Boolean is
begin
for Some_Element of V loop
if Some_Element = S then
return True;
end if;
end loop;
return False;
end Is_In;
function "and"(Left, Right: Vector) return Vector is
V: Vector := Empty_Vector;
begin
for Some_Element of Left loop
if Is_In(Some_Element, Right) then
V := V & Some_Element;
end if;
end loop;
return V;
end "and";
function "or"(Left, Right: Vector) return Vector is
V: Vector := Left; -- all sources in Left
begin
for Some_Element of Right loop
if not Is_In(Some_Element, Left) then
V := V & Some_Element;
end if;
end loop;
return V;
end "or";
function Empty(Vec: Vector) return Boolean
renames Is_Empty;
procedure Iterate(The_Sources: Vector) is
begin
for Some_Element in The_Sources loop
Do_Something(Element(Some_Element));
end loop;
end Iterate;
function Same_Vector(U,V: Vector) return Boolean is
begin
raise Program_Error with "there is no need to call this function";
return False; -- this avoices a compiler warning
end Same_Vector;
end Generic_Inverted_Index;
| 27.686747 | 72 | 0.59356 | false | false | true |
5,413 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C52104M.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT LENGTHS MUST MATCH IN ARRAY AND SLICE ASSIGNMENTS.
-- MORE SPECIFICALLY, TEST THAT ATTEMPTED ASSIGNMENTS BETWEEN
-- ARRAYS WITH NON-MATCHING LENGTHS LEAVE THE DESTINATION ARRAY
-- INTACT AND CAUSE CONSTRAINT_ERROR TO BE RAISED.
-- (OVERLAPS BETWEEN THE OPERANDS OF THE ASSIGNMENT STATEMENT
-- ARE TREATED ELSEWHERE.)
-- THIS IS THE THIRD FILE IN
-- DIVISION C : NON-NULL LENGTHS NOT DETERMINABLE STATICALLY.
-- RM 07/20/81
-- SPS 3/22/83
WITH REPORT;
PROCEDURE C52104M IS
USE REPORT ;
BEGIN
TEST( "C52104M" , "CHECK THAT IN ARRAY ASSIGNMENTS AND IN SLICE" &
" ASSIGNMENTS THE LENGTHS MUST MATCH" );
-- ( EACH DIVISION COMPRISES 3 FILES,
-- COVERING RESPECTIVELY THE FIRST
-- 3 , NEXT 2 , AND LAST 3 OF THE 8
-- SELECTIONS FOR THE DIVISION.)
-------------------------------------------------------------------
-- (7) UNSLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' (BY
-- THEMSELVES).
DECLARE
ARR71 : STRING( IDENT_INT(1)..IDENT_INT(5) ) := "ABCDE" ;
ARR72 : STRING( IDENT_INT(5)..IDENT_INT(8) ) := "FGHI" ;
BEGIN
-- STRING ASSIGNMENT:
ARR72 := ARR71 ;
FAILED( "EXCEPTION NOT RAISED - SUBTEST 7" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
-- CHECKING THE VALUES AFTER THE STRING ASSIGNMENT:
IF ARR72 /= "FGHI"
THEN
FAILED( "ORIGINAL VALUE ALTERED (7)" );
END IF;
WHEN OTHERS =>
FAILED( "WRONG EXCEPTION RAISED - SUBTEST 7" );
END ;
-------------------------------------------------------------------
-- (8) SLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' , WITH
-- STRING LITERALS.
--
DECLARE
ARR82 : STRING( IDENT_INT(5)..IDENT_INT(9) ) := "QBCDE" ;
BEGIN
-- STRING LITERAL ASSIGNMENT:
ARR82( IDENT_INT(5)..IDENT_INT(9) )
( IDENT_INT(6)..IDENT_INT(9) ) := "EIN" ;
FAILED( "EXCEPTION NOT RAISED - SUBTEST 8" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
-- CHECKING THE VALUES AFTER THE SLICE ASSIGNMENT:
IF ARR82 /= "QBCDE" OR
ARR82( IDENT_INT(5)..IDENT_INT(9) ) /= "QBCDE"
THEN
FAILED( "LHS ARRAY ALTERED (8)" );
END IF;
WHEN OTHERS =>
FAILED( "WRONG EXCEPTION RAISED - SUBTEST 8" );
END ;
-------------------------------------------------------------------
-- (9) SLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' (BY
-- THEMSELVES).
--
DECLARE
SUBTYPE TA92 IS STRING( IDENT_INT(5)..IDENT_INT(9) ) ;
ARR91 : STRING( IDENT_INT(1)..IDENT_INT(7) ) := "ABCDEFG" ;
ARR92 : TA92 ;
BEGIN
-- INITIALIZATION OF LHS ARRAY:
ARR92( IDENT_INT(5)..IDENT_INT(9) ) := "QUINC" ;
-- STRING SLICE ASSIGNMENT:
ARR92( IDENT_INT(5)..IDENT_INT(9) )
( IDENT_INT(6)..IDENT_INT(9) ) :=
ARR91
( IDENT_INT(1)..IDENT_INT(7) )
( IDENT_INT(1)..IDENT_INT(6) )
( IDENT_INT(1)..IDENT_INT(6) ) ;
FAILED( "EXCEPTION NOT RAISED - SUBTEST 9" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
-- CHECKING THE VALUES AFTER THE SLICE ASSIGNMENT:
IF ARR92 /= "QUINC" OR
ARR92( IDENT_INT(5)..IDENT_INT(9) ) /= "QUINC"
THEN
FAILED( "LHS VALUE ALTERED (9)" );
END IF;
WHEN OTHERS =>
FAILED( "WRONG EXCEPTION RAISED - SUBTEST 9" );
END ;
-------------------------------------------------------------------
RESULT ;
END C52104M;
| 29.259459 | 79 | 0.507851 | false | false | true |
5,263 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CC1301A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT DEFAULT GENERIC SUBPROGRAM PARAMETERS WORK CORRECTLY,
-- INCLUDING OVERLOADED AND PREDEFINED OPERATOR_SYMBOLS,
-- AND SUBPROGRAMS HIDDEN AT THE INSTANTIATION.
-- BOTH KINDS OF DEFAULTS ARE TESTED, FOR BOTH PROCEDURES
-- AND FUNCTIONS.
-- DAT 8/14/81
-- JBG 5/5/83
-- JBG 8/3/83
WITH REPORT; USE REPORT;
PROCEDURE CC1301A IS
FUNCTION "-" (R, S : INTEGER) RETURN INTEGER;
FUNCTION NEXT (X : INTEGER) RETURN INTEGER;
PROCEDURE BUMP (X : IN OUT INTEGER);
GENERIC
WITH FUNCTION "*" (A, B : INTEGER) RETURN INTEGER IS "-";
WITH FUNCTION "+" (R, S: INTEGER) RETURN INTEGER IS
STANDARD."+";
WITH FUNCTION "-" (A, B : INTEGER) RETURN INTEGER IS <> ;
WITH FUNCTION NEXTO (Q : INTEGER) RETURN INTEGER IS NEXT ;
WITH PROCEDURE BUMPO (A : IN OUT INTEGER) IS BUMP;
WITH FUNCTION NEXT (Q : INTEGER) RETURN INTEGER IS <> ;
WITH PROCEDURE BUMP (Q : IN OUT INTEGER) IS <> ;
TYPE INTEGER IS RANGE <> ;
WITH FUNCTION "*" (A , B : INTEGER) RETURN INTEGER IS <> ;
WITH FUNCTION "-" (A, B : INTEGER) RETURN INTEGER IS <> ;
WITH FUNCTION NEXT (Q : INTEGER) RETURN INTEGER IS <> ;
WITH PROCEDURE BUMP (Z : IN OUT INTEGER) IS <> ;
PACKAGE PKG IS
SUBTYPE INT IS STANDARD.INTEGER;
DIFF : INT := -999;
END PKG;
TYPE NEWINT IS NEW INTEGER RANGE -1000 .. 1000;
FUNCTION PLUS (Q1, Q2 : INTEGER) RETURN INTEGER RENAMES "+";
FUNCTION "+" (X, Y : INTEGER) RETURN INTEGER IS
BEGIN
RETURN PLUS (X, PLUS (Y, -10));
-- (X + Y - 10)
END "+";
FUNCTION "-" (R, S : INTEGER) RETURN INTEGER IS
BEGIN
RETURN - R + S;
-- (-R + S - 10)
END "-";
FUNCTION NEXT (X : INTEGER) RETURN INTEGER IS
BEGIN
RETURN X + 1;
-- (X + 1 - 10)
-- (X - 9)
END NEXT;
PROCEDURE BUMP (X : IN OUT INTEGER) IS
BEGIN
X := NEXT (X);
-- (X := X - 9)
END BUMP;
PACKAGE BODY PKG IS
W : INTEGER;
WI : INT;
BEGIN
W := NEXT (INTEGER'(3) * 4 - 2);
-- (W := (4 ** 3 - 2) - 1)
-- (W := 61)
BUMP (W);
-- (W := 61 + 7)
-- (W := 68)
WI := NEXT (INT'(3) * 4 - 2 + NEXTO (0));
-- (3 * 4) => (3 - 4) => (-3 + 4 - 10) = -9
-- ((-9) - 2) => (2 + 2 - (-9) - 20) = -7
-- (-7 + (-9)) => -16
-- (WI := 7 - (-16)) => (WI := 23)
BUMPO (WI);
-- (WI := 23 - 9) (= 14)
BUMP (WI);
-- (WI := 14 - 9) (= 5)
DIFF := STANDARD."-" (INT(W), WI);
-- (DIFF := 68 - 5) (= 63)
END PKG;
FUNCTION "*" (Y, X : NEWINT) RETURN NEWINT IS
BEGIN
RETURN X ** INTEGER(Y);
-- (X,Y) (Y ** X)
END "*";
FUNCTION NEXT (Z : NEWINT) RETURN NEWINT IS
BEGIN
RETURN Z - 1;
-- (Z - 1)
END NEXT;
PROCEDURE BUMP (ZZ : IN OUT NEWINT) IS
BEGIN
FAILED ("WRONG PROCEDURE CALLED");
END BUMP;
BEGIN
TEST ("CC1301A", "DEFAULT GENERIC SUBPROGRAM PARAMETERS");
DECLARE
PROCEDURE BUMP (QQQ : IN OUT NEWINT) IS
BEGIN
QQQ := QQQ + 7;
-- (QQQ + 7)
END BUMP;
FUNCTION NEXT (Q7 : INTEGER) RETURN INTEGER IS
BEGIN
RETURN Q7 - 17;
-- (-Q7 + 17 - 10)
-- (7 - Q7)
END NEXT;
FUNCTION "-" (Q3, Q4 : INTEGER) RETURN INTEGER IS
BEGIN
RETURN -Q3 + Q4 + Q4;
-- (-Q3 + Q4 - 10 + Q4 - 10) = (Q4 + Q4 - Q3 - 20)
END "-";
PACKAGE P1 IS NEW PKG (INTEGER => NEWINT);
BEGIN
IF P1.DIFF /= 63 THEN
FAILED ("WRONG DEFAULT SUBPROGRAM PARAMETERS");
END IF;
END;
RESULT;
END CC1301A;
| 31.89697 | 79 | 0.514155 | false | false | true |
1,995 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CD7101D.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT FOR MIN_INT AND MAX_INT IN PACKAGE SYSTEM,
-- INTEGER'FIRST >= MIN_INT AND INTEGER'LAST <= MAX_INT.
-- HISTORY:
-- JET 09/10/87 CREATED ORIGINAL TEST.
WITH SYSTEM;
WITH REPORT; USE REPORT;
PROCEDURE CD7101D IS
BEGIN
TEST ("CD7101D", "CHECK THAT FOR MIN_INT AND MAX_INT IN PACKAGE " &
"SYSTEM, INTEGER'FIRST >= MIN_INT AND INTEGER'" &
"LAST <= MAX_INT");
IF INTEGER'POS (INTEGER'FIRST) < SYSTEM.MIN_INT THEN
FAILED ("INCORRECT VALUE FOR SYSTEM.MIN_INT");
END IF;
IF INTEGER'POS (INTEGER'LAST) > SYSTEM.MAX_INT THEN
FAILED ("INCORRECT VALUE FOR SYSTEM.MAX_INT");
END IF;
RESULT;
END CD7101D;
| 36.944444 | 79 | 0.655138 | false | false | true |
19 | ada | Ada | [
"Apache-2.0"
] | null |
end ${self.name};
| 6.333333 | 17 | 0.578947 | false | false | false |
4,214 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C52103Q.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT LENGTHS MUST MATCH IN ARRAY AND SLICE ASSIGNMENTS.
-- MORE SPECIFICALLY, TEST THAT ARRAY ASSIGNMENTS WITH MATCHING
-- LENGTHS DO NOT CAUSE CONSTRAINT_ERROR TO BE RAISED AND
-- ARE PERFORMED CORRECTLY.
-- (OVERLAPS BETWEEN THE OPERANDS OF THE ASSIGNMENT STATEMENT
-- ARE TREATED ELSWEWHERE.)
-- THIS IS THE SECOND FILE IN
-- DIVISION D : NULL LENGTHS NOT DETERMINABLE STATICALLY.
-- RM 07/20/81
-- SPS 2/18/83
WITH REPORT;
PROCEDURE C52103Q IS
USE REPORT ;
BEGIN
TEST( "C52103Q" , "CHECK THAT IN ARRAY ASSIGNMENTS AND IN SLICE" &
" ASSIGNMENTS THE LENGTHS MUST MATCH" );
-- ( EACH DIVISION COMPRISES 3 FILES,
-- COVERING RESPECTIVELY THE FIRST
-- 3 , NEXT 2 , AND LAST 3 OF THE 8
-- SELECTIONS FOR THE DIVISION.)
-------------------------------------------------------------------
-- (5) UNSLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS
-- WERE DEFINED WITHOUT EVER USING THE "BOX" SYMBOL
-- AND FOR WHICH THE COMPONENT TYPE IS 'CHARACTER' .
--
DECLARE
TYPE TA51 IS ARRAY(
INTEGER RANGE IDENT_INT(11)..IDENT_INT(10)
) OF CHARACTER ;
ARR51 : TA51 ;
BEGIN
-- ARRAY ASSIGNMENT (WITH STRING AGGREGATE):
ARR51 := "" ;
-- CHECKING THE VALUES AFTER THE ASSIGNMENT:
IF ARR51 /= ""
THEN
FAILED( "ARRAY ASSIGNMENT NOT CORRECT (5)" );
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED( "EXCEPTION RAISED - SUBTEST 5" );
END ;
-------------------------------------------------------------------
-- (14) SLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS
-- WERE DEFINED USING THE "BOX" SYMBOL
-- AND FOR WHICH THE COMPONENT TYPE IS 'CHARACTER' .
DECLARE
TYPE TABOX4 IS ARRAY( INTEGER RANGE <> ) OF CHARACTER ;
SUBTYPE TABOX42 IS TABOX4( IDENT_INT(11)..IDENT_INT(15) );
ARRX42 : TABOX42 ;
BEGIN
-- INITIALIZATION OF LHS ARRAY:
ARRX42 := "QUINC" ;
-- NULL SLICE ASSIGNMENT:
ARRX42( IDENT_INT(13)..IDENT_INT(12) ) := "" ;
-- CHECKING THE VALUES AFTER THE SLICE ASSIGNMENT:
IF ARRX42 /= "QUINC" OR
ARRX42( IDENT_INT(11)..IDENT_INT(15) ) /= "QUINC"
THEN
FAILED( "SLICE ASSIGNMENT NOT CORRECT (14)" );
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED( "EXCEPTION RAISED - SUBTEST 14" );
END ;
-------------------------------------------------------------------
RESULT ;
END C52103Q;
| 29.263889 | 79 | 0.540342 | false | false | true |
3,115 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CD3015C.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT AN ENUMERATION REPRESENTATION CLAUSE FOR A DERIVED
-- TYPE CAN BE GIVEN IN THE VISIBLE OR PRIVATE PART OF A PACKAGE
-- FOR A DERIVED TYPE DECLARED IN THE VISIBLE PART, WHERE NO
-- ENUMERATION CLAUSE HAS BEEN GIVEN FOR THE PARENT.
-- HISTORY
-- DHH 10/01/87 CREATED ORIGINAL TEST
-- DHH 03/29/89 CHANGE FROM 'A' TEST TO 'C' TEST AND FROM '.DEP'
-- '.ADA'. ADDED CHECK ON REPRESENTATION CLAUSES.
WITH REPORT; USE REPORT;
WITH ENUM_CHECK; -- CONTAINS A CALL TO 'FAILED'.
PROCEDURE CD3015C IS
BEGIN
TEST ("CD3015C", "CHECK THAT AN ENUMERATION " &
"REPRESENTATION CLAUSE FOR A DERIVED TYPE CAN " &
"BE GIVEN IN THE VISIBLE OR PRIVATE PART OF A " &
"PACKAGE FOR A DERIVED TYPE DECLARED IN THE " &
"VISIBLE PART, WHERE NO ENUMERATION CLAUSE HAS " &
"BEEN GIVEN FOR THE PARENT");
DECLARE
PACKAGE PACK IS
TYPE MAIN IS (RED,BLUE,YELLOW);
TYPE HUE IS NEW MAIN;
TYPE NEWHUE IS NEW MAIN;
FOR HUE USE (RED => 1, BLUE => 16, YELLOW => 32);
PRIVATE
FOR NEWHUE USE (RED => 16, BLUE => 17, YELLOW => 18);
TYPE INT1 IS RANGE 1 .. 32;
FOR INT1'SIZE USE HUE'SIZE;
TYPE INT2 IS RANGE 16 .. 18;
FOR INT2'SIZE USE NEWHUE'SIZE;
PROCEDURE CHECK_1 IS NEW ENUM_CHECK(HUE, INT1);
PROCEDURE CHECK_2 IS NEW ENUM_CHECK(NEWHUE, INT2);
END PACK;
PACKAGE BODY PACK IS
BEGIN
CHECK_1 (RED, 1, "HUE");
CHECK_2 (YELLOW, 18, "NEWHUE");
END PACK;
BEGIN
NULL;
END;
RESULT;
END CD3015C;
| 37.53012 | 79 | 0.591653 | false | false | true |
93 | ada | Ada | [
"Info-ZIP"
] | 1 | for I in 1..5 loop
for J in 1..I loop
Put("*");
end loop;
New_Line;
end loop;
| 13.285714 | 21 | 0.526882 | false | false | true |
12,662 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C35507C.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT THE ATTRIBUTES 'IMAGE' AND 'VALUE' YIELD THE CORRECT
-- RESULTS WHEN THE PREFIX IS A CHARACTER TYPE.
-- SUBTESTS ARE:
-- (A). TESTS FOR IMAGE.
-- (B). TESTS FOR VALUE.
-- HISTORY:
-- RJW 05/29/86 CREATED ORIGINAL TEST.
-- BCB 08/18/87 CHANGED HEADER TO STANDARD HEADER FORMAT.
-- CORRECTED ERROR MESSAGES AND ADDED CALLS TO
-- IDENT_STR.
WITH REPORT; USE REPORT;
PROCEDURE C35507C IS
TYPE CHAR IS ('A', 'a');
TYPE NEWCHAR IS NEW CHAR;
FUNCTION IDENT (CH : CHAR) RETURN CHAR IS
BEGIN
RETURN CHAR'VAL (IDENT_INT (CHAR'POS (CH)));
END IDENT;
FUNCTION IDENT (CH : NEWCHAR) RETURN NEWCHAR IS
BEGIN
RETURN NEWCHAR'VAL (IDENT_INT (NEWCHAR'POS (CH)));
END IDENT;
PROCEDURE CHECK_BOUND (STR1, STR2 : STRING) IS
BEGIN
IF STR1'FIRST /= 1 THEN
FAILED ( "INCORRECT LOWER BOUND FOR " & STR2 &
"'IMAGE ('" & STR1 & "')" );
END IF;
END CHECK_BOUND;
BEGIN
TEST( "C35507C" , "CHECK THAT THE ATTRIBUTES 'IMAGE' AND " &
"'VALUE' YIELD THE CORRECT RESULTS WHEN THE " &
"PREFIX IS A CHARACTER TYPE" );
BEGIN -- (A).
IF CHAR'IMAGE ('A') /= "'A'" THEN
FAILED ( "INCORRECT IMAGE FOR CHAR'('A')" );
END IF;
CHECK_BOUND (CHAR'IMAGE ('A'), "CHAR");
IF CHAR'IMAGE ('a') /= "'a'" THEN
FAILED ( "INCORRECT IMAGE FOR CHAR'('a')" );
END IF;
CHECK_BOUND (CHAR'IMAGE ('a'), "CHAR");
IF NEWCHAR'IMAGE ('A') /= "'A'" THEN
FAILED ( "INCORRECT IMAGE FOR NEWCHAR'('A')" );
END IF;
CHECK_BOUND (NEWCHAR'IMAGE ('A'), "NEWCHAR");
IF NEWCHAR'IMAGE ('a') /= "'a'" THEN
FAILED ( "INCORRECT IMAGE FOR NEWCHAR'('a')" );
END IF;
CHECK_BOUND (NEWCHAR'IMAGE ('a'), "NEWCHAR");
IF CHAR'IMAGE (IDENT ('A')) /= "'A'" THEN
FAILED ( "INCORRECT IMAGE FOR CHAR'( IDENT ('A'))" );
END IF;
CHECK_BOUND (CHAR'IMAGE (IDENT ('A')), "IDENT OF CHAR");
IF CHAR'IMAGE (IDENT ('a')) /= "'a'" THEN
FAILED ( "INCORRECT IMAGE FOR CHAR'( IDENT ('a'))" );
END IF;
CHECK_BOUND (CHAR'IMAGE (IDENT ('a')), "IDENT OF CHAR");
IF NEWCHAR'IMAGE (IDENT ('A')) /= "'A'" THEN
FAILED ( "INCORRECT IMAGE FOR NEWCHAR'( IDENT ('A'))" );
END IF;
CHECK_BOUND (NEWCHAR'IMAGE (IDENT ('A')), "IDENT OF NEWCHAR");
IF NEWCHAR'IMAGE (IDENT ('a')) /= "'a'" THEN
FAILED ( "INCORRECT IMAGE FOR NEWCHAR'( IDENT ('a'))" );
END IF;
CHECK_BOUND (NEWCHAR'IMAGE (IDENT ('a')), "IDENT OF NEWCHAR");
FOR CH IN CHARACTER'VAL (32) .. CHARACTER'VAL (126) LOOP
IF CHARACTER'IMAGE (CH) /= ("'" & CH) & "'" THEN
FAILED ( "INCORRECT IMAGE FOR CHARACTER'(" &
CH & ")" );
END IF;
CHECK_BOUND (CHARACTER'IMAGE (CH), "CHARACTER");
END LOOP;
FOR CH IN CHARACTER'VAL (0) .. CHARACTER'VAL (31) LOOP
CHECK_BOUND (CHARACTER'IMAGE (CH), "CHARACTER");
END LOOP;
CHECK_BOUND (CHARACTER'IMAGE (CHARACTER'VAL (127)),
"CHARACTER");
END;
---------------------------------------------------------------
DECLARE -- (B).
SUBTYPE SUBCHAR IS CHARACTER
RANGE CHARACTER'VAL (127) .. CHARACTER'VAL (127);
BEGIN
FOR CH IN CHARACTER'VAL (32) .. CHARACTER'VAL (126) LOOP
IF SUBCHAR'VALUE (("'" & CH) & "'") /= CH THEN
FAILED ( "INCORRECT SUBCHAR'VALUE FOR " & CH );
END IF;
END LOOP;
FOR CH IN CHARACTER'VAL (0) .. CHARACTER'VAL (31) LOOP
IF SUBCHAR'VALUE (CHARACTER'IMAGE (CH)) /= CH THEN
FAILED ( "INCORRECT SUBCHAR'VALUE FOR " &
CHARACTER'IMAGE (CH) );
END IF;
END LOOP;
IF SUBCHAR'VALUE (CHARACTER'IMAGE (CHARACTER'VAL (127))) /=
CHARACTER'VAL (127) THEN
FAILED ( "INCORRECT SUBCHAR'VALUE FOR " &
"CHARACTER'VAL (127)" );
END IF;
END;
BEGIN
IF CHAR'VALUE ("'A'") /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR CHAR'(""'A'"")" );
END IF;
IF CHAR'VALUE ("'a'") /= 'a' THEN
FAILED ( "INCORRECT VALUE FOR CHAR'(""'a'"")" );
END IF;
IF NEWCHAR'VALUE ("'A'") /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'(""'A'"")" );
END IF;
IF NEWCHAR'VALUE ("'a'") /= 'a' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'(""'a'"")" );
END IF;
END;
BEGIN
IF CHAR'VALUE (IDENT_STR("'A'")) /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR CHAR'(IDENT_STR" &
"(""'A'""))" );
END IF;
IF CHAR'VALUE (IDENT_STR("'a'")) /= 'a' THEN
FAILED ( "INCORRECT VALUE FOR CHAR'(IDENT_STR" &
"(""'a'""))" );
END IF;
IF NEWCHAR'VALUE (IDENT_STR("'A'")) /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'(IDENT_STR" &
"(""'A'""))" );
END IF;
IF NEWCHAR'VALUE (IDENT_STR("'a'")) /= 'a' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'(IDENT_STR" &
"(""'a'""))" );
END IF;
END;
BEGIN
IF CHAR'VALUE (IDENT_STR ("'B'")) = 'A' THEN
FAILED ( "NO EXCEPTION RAISED " &
"FOR CHAR'VALUE (IDENT_STR (""'B'"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED " &
"FOR CHAR'VALUE (IDENT_STR (""'B'"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHAR'VALUE (IDENT_STR (""'B'""))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_CHAR (ASCII.HT) & "'A'") = 'A' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE " &
"(IDENT_CHAR (ASCII.HT) & ""'A'"") - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE " &
"(IDENT_CHAR (ASCII.HT) & ""'A'"") - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE " &
"(IDENT_CHAR (ASCII.HT) & ""'A'"")" );
END;
BEGIN
IF CHARACTER'VALUE ("'B'" & IDENT_CHAR (ASCII.HT)) = 'B' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (""'B'"" & " &
"IDENT_CHAR (ASCII.HT)) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (""'B'"" & " &
"IDENT_CHAR (ASCII.HT)) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE (""'B'"" & " &
"IDENT_CHAR (ASCII.HT)) " );
END;
BEGIN
IF CHARACTER'VALUE ("'C'" & IDENT_CHAR (ASCII.BEL)) = 'C'
THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (""'C'"" & " &
"IDENT_CHAR (ASCII.BEL)) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (""'C'"" & " &
"IDENT_CHAR (ASCII.BEL)) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE (""'C'"" & " &
"IDENT_CHAR (ASCII.BEL))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_STR ("'")) = ''' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE (IDENT_STR (""'""))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_STR ("''")) = ''' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""''"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""''"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE (IDENT_STR (""''""))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_STR ("'A")) = 'A' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'A"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'A"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE IDENT_STR (""'A""))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_STR ("A'")) = 'A' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""A'"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""A'"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE (IDENT_STR (""A'""))" );
END;
BEGIN
IF CHARACTER'VALUE (IDENT_STR ("'AB'")) = 'A' THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'AB'"")) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHARACTER'VALUE (IDENT_STR (""'AB'"")) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR CHARACTER'VALUE IDENT_STR (""'AB'""))" );
END;
RESULT;
END C35507C;
| 35.074792 | 79 | 0.460038 | false | false | true |
1,047 | ada | Ada | [
"Info-ZIP"
] | 1 | with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Pattern; use Cairo.Pattern;
with Cairo.Image_Surface; use Cairo.Image_Surface;
with Ada.Numerics;
procedure Sphere is
subtype Dub is Glib.Gdouble;
Surface : Cairo_Surface;
Cr : Cairo_Context;
Pat : Cairo_Pattern;
Status_Out : Cairo_Status;
M_Pi : constant Dub := Dub (Ada.Numerics.Pi);
begin
Surface := Create (Cairo_Format_ARGB32, 512, 512);
Cr := Create (Surface);
Pat :=
Cairo.Pattern.Create_Radial (230.4, 204.8, 51.1, 204.8, 204.8, 256.0);
Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 0.0, 1.0, 1.0, 1.0, 1.0);
Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 1.0, 0.0, 0.0, 0.0, 1.0);
Cairo.Set_Source (Cr, Pat);
Cairo.Arc (Cr, 256.0, 256.0, 153.6, 0.0, 2.0 * M_Pi);
Cairo.Fill (Cr);
Cairo.Pattern.Destroy (Pat);
Status_Out := Write_To_Png (Surface, "SphereAda.png");
pragma Assert (Status_Out = Cairo_Status_Success);
end Sphere;
| 33.774194 | 76 | 0.630372 | false | false | true |
662 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Numerics.Complex_Arrays; use Ada.Numerics.Complex_Arrays;
with Ada.Complex_Text_IO; use Ada.Complex_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Complex_Elementary_Functions;
with Generic_FFT;
procedure Example is
function FFT is new Generic_FFT (Ada.Numerics.Complex_Arrays);
X : Complex_Vector := (1..4 => (1.0, 0.0), 5..8 => (0.0, 0.0));
Y : Complex_Vector := FFT (X);
begin
Put_Line (" X FFT X ");
for I in Y'Range loop
Put (X (I - Y'First + X'First), Aft => 3, Exp => 0);
Put (" ");
Put (Y (I), Aft => 3, Exp => 0);
New_Line;
end loop;
end;
| 31.52381 | 67 | 0.595166 | false | false | true |
9,921 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C74004A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT OPERATIONS DEPENDING ON THE FULL DECLARATION OF A
-- PRIVATE TYPE ARE AVAILABLE WITHIN THE PACKAGE BODY.
-- HISTORY:
-- BCB 04/05/88 CREATED ORIGINAL TEST.
-- PWN 01/31/95 REMOVED INCONSISTENCIES WITH ADA 9X.
WITH REPORT; USE REPORT;
PROCEDURE C74004A IS
PACKAGE P IS
TYPE PR IS PRIVATE;
TYPE ARR1 IS LIMITED PRIVATE;
TYPE ARR2 IS PRIVATE;
TYPE REC (D : INTEGER) IS PRIVATE;
TYPE ACC IS PRIVATE;
TYPE TSK IS LIMITED PRIVATE;
TYPE FLT IS LIMITED PRIVATE;
TYPE FIX IS LIMITED PRIVATE;
TASK TYPE T IS
ENTRY ONE(V : IN OUT INTEGER);
END T;
PROCEDURE CHECK (V : ARR2);
PRIVATE
TYPE PR IS NEW INTEGER;
TYPE ARR1 IS ARRAY(1..5) OF INTEGER;
TYPE ARR2 IS ARRAY(1..5) OF BOOLEAN;
TYPE REC (D : INTEGER) IS RECORD
COMP1 : INTEGER;
COMP2 : BOOLEAN;
END RECORD;
TYPE ACC IS ACCESS INTEGER;
TYPE TSK IS NEW T;
TYPE FLT IS DIGITS 5;
TYPE FIX IS DELTA 2.0**(-1) RANGE -100.0 .. 100.0;
END P;
PACKAGE BODY P IS
X1, X2, X3 : PR;
BOOL : BOOLEAN := IDENT_BOOL(FALSE);
VAL : INTEGER := IDENT_INT(0);
FVAL : FLOAT := 0.0;
ST : STRING(1..2);
O1 : ARR1 := (1,2,3,4,5);
Y1 : ARR2 := (FALSE,TRUE,FALSE,TRUE,FALSE);
Y2 : ARR2 := (OTHERS => TRUE);
Y3 : ARR2 := (OTHERS => FALSE);
Z1 : REC(0) := (0,1,FALSE);
W1, W2 : ACC := NEW INTEGER'(0);
V1 : TSK;
TASK BODY T IS
BEGIN
ACCEPT ONE(V : IN OUT INTEGER) DO
V := IDENT_INT(10);
END ONE;
END T;
PROCEDURE CHECK (V : ARR2) IS
BEGIN
IF V /= (TRUE,FALSE,TRUE,FALSE,TRUE) THEN
FAILED ("IMPROPER VALUE PASSED AS AGGREGATE");
END IF;
END CHECK;
BEGIN
TEST ("C74004A", "CHECK THAT OPERATIONS DEPENDING ON THE " &
"FULL DECLARATION OF A PRIVATE TYPE ARE " &
"AVAILABLE WITHIN THE PACKAGE BODY");
X1 := 10;
X2 := 5;
X3 := X1 + X2;
IF X3 /= 15 THEN
FAILED ("IMPROPER RESULT FROM ADDITION OPERATOR");
END IF;
X3 := X1 - X2;
IF X3 /= 5 THEN
FAILED ("IMPROPER RESULT FROM SUBTRACTION OPERATOR");
END IF;
X3 := X1 * X2;
IF X3 /= 50 THEN
FAILED ("IMPROPER RESULT FROM MULTIPLICATION OPERATOR");
END IF;
X3 := X1 / X2;
IF X3 /= 2 THEN
FAILED ("IMPROPER RESULT FROM DIVISION OPERATOR");
END IF;
X3 := X1 ** 2;
IF X3 /= 100 THEN
FAILED ("IMPROPER RESULT FROM EXPONENTIATION OPERATOR");
END IF;
BOOL := X1 < X2;
IF BOOL THEN
FAILED ("IMPROPER RESULT FROM LESS THAN OPERATOR");
END IF;
BOOL := X1 > X2;
IF NOT BOOL THEN
FAILED ("IMPROPER RESULT FROM GREATER THAN OPERATOR");
END IF;
BOOL := X1 <= X2;
IF BOOL THEN
FAILED ("IMPROPER RESULT FROM LESS THAN OR EQUAL TO " &
"OPERATOR");
END IF;
BOOL := X1 >= X2;
IF NOT BOOL THEN
FAILED ("IMPROPER RESULT FROM GREATER THAN OR EQUAL " &
"TO OPERATOR");
END IF;
X3 := X1 MOD X2;
IF X3 /= 0 THEN
FAILED ("IMPROPER RESULT FROM MOD OPERATOR");
END IF;
X3 := X1 REM X2;
IF X3 /= 0 THEN
FAILED ("IMPROPER RESULT FROM REM OPERATOR");
END IF;
X3 := ABS(X1);
IF X3 /= 10 THEN
FAILED ("IMPROPER RESULT FROM ABS OPERATOR - 1");
END IF;
X1 := -10;
X3 := ABS(X1);
IF X3 /= 10 THEN
FAILED ("IMPROPER RESULT FROM ABS OPERATOR - 2");
END IF;
X3 := PR'BASE'FIRST;
IF X3 /= PR(INTEGER'FIRST) THEN
FAILED ("IMPROPER RESULT FROM 'BASE'FIRST");
END IF;
X3 := PR'FIRST;
IF X3 /= PR(INTEGER'FIRST) THEN
FAILED ("IMPROPER RESULT FROM 'FIRST");
END IF;
VAL := PR'WIDTH;
IF NOT EQUAL(VAL,INTEGER'WIDTH) THEN
FAILED ("IMPROPER RESULT FROM 'WIDTH");
END IF;
VAL := PR'POS(X3);
IF NOT EQUAL(VAL,INTEGER'FIRST) THEN
FAILED ("IMPROPER RESULT FROM 'POS");
END IF;
X3 := PR'VAL(VAL);
IF X3 /= PR(INTEGER'FIRST) THEN
FAILED ("IMPROPER RESULT FROM 'VAL");
END IF;
X3 := PR'SUCC(X2);
IF X3 /= 6 THEN
FAILED ("IMPROPER RESULT FROM 'SUCC");
END IF;
X3 := PR'PRED(X2);
IF X3 /= 4 THEN
FAILED ("IMPROPER RESULT FROM 'PRED");
END IF;
ST := PR'IMAGE(X3);
IF ST /= INTEGER'IMAGE(INTEGER(X3)) THEN
FAILED ("IMPROPER RESULT FROM 'IMAGE");
END IF;
X3 := PR'VALUE(ST);
IF X3 /= PR(INTEGER'VALUE(ST)) THEN
FAILED ("IMPROPER RESULT FROM 'VALUE");
END IF;
CHECK ((TRUE,FALSE,TRUE,FALSE,TRUE));
IF O1(2) /= IDENT_INT(2) THEN
FAILED ("IMPROPER VALUE FROM INDEXING");
END IF;
IF O1(2..4) /= (2,3,4) THEN
FAILED ("IMPROPER VALUES FROM SLICING");
END IF;
IF VAL IN O1'RANGE THEN
FAILED ("IMPROPER RESULT FROM 'RANGE");
END IF;
VAL := O1'LENGTH;
IF NOT EQUAL(VAL,5) THEN
FAILED ("IMPROPER RESULT FROM 'LENGTH");
END IF;
Y3 := Y1(1..2) & Y2(3..5);
IF Y3 /= (FALSE,TRUE,TRUE,TRUE,TRUE) THEN
FAILED ("IMPROPER RESULT FROM CATENATION");
END IF;
Y3 := NOT Y1;
IF Y3 /= (TRUE,FALSE,TRUE,FALSE,TRUE) THEN
FAILED ("IMPROPER RESULT FROM NOT OPERATOR");
END IF;
Y3 := Y1 AND Y2;
IF Y3 /= (FALSE,TRUE,FALSE,TRUE,FALSE) THEN
FAILED ("IMPROPER RESULT FROM AND OPERATOR");
END IF;
Y3 := Y1 OR Y2;
IF Y3 /= (TRUE,TRUE,TRUE,TRUE,TRUE) THEN
FAILED ("IMPROPER RESULT FROM OR OPERATOR");
END IF;
Y3 := Y1 XOR Y2;
IF Y3 /= (TRUE,FALSE,TRUE,FALSE,TRUE) THEN
FAILED ("IMPROPER RESULT FROM XOR OPERATOR");
END IF;
VAL := Z1.COMP1;
IF NOT EQUAL(VAL,1) THEN
FAILED ("IMPROPER RESULT FROM SELECTION OF RECORD " &
"COMPONENTS");
END IF;
W1 := NEW INTEGER'(0);
IF NOT EQUAL(W1.ALL,0) THEN
FAILED ("IMPROPER RESULT FROM ALLOCATION");
END IF;
W1 := NULL;
IF W1 /= NULL THEN
FAILED ("IMPROPER RESULT FROM NULL LITERAL");
END IF;
VAL := W2.ALL;
IF NOT EQUAL(VAL,0) THEN
FAILED ("IMPROPER RESULT FROM SELECTED COMPONENT");
END IF;
BOOL := V1'CALLABLE;
IF NOT BOOL THEN
FAILED ("IMPROPER RESULT FROM 'CALLABLE");
END IF;
BOOL := V1'TERMINATED;
IF BOOL THEN
FAILED ("IMPROPER RESULT FROM 'TERMINATED");
END IF;
V1.ONE(VAL);
IF NOT EQUAL(VAL,10) THEN
FAILED ("IMPROPER RESULT RETURNED FROM ENTRY SELECTION");
END IF;
IF NOT (FLT(1.0) IN FLT) THEN
FAILED ("IMPROPER RESULT FROM IMPLICIT CONVERSION");
END IF;
VAL := FLT'DIGITS;
IF NOT EQUAL(VAL,5) THEN
FAILED ("IMPROPER RESULT FROM 'DIGITS");
END IF;
BOOL := FLT'MACHINE_ROUNDS;
BOOL := FLT'MACHINE_OVERFLOWS;
VAL := FLT'MACHINE_RADIX;
VAL := FLT'MACHINE_MANTISSA;
VAL := FLT'MACHINE_EMAX;
VAL := FLT'MACHINE_EMIN;
FVAL := FIX'DELTA;
IF FVAL /= 2.0**(-1) THEN
FAILED ("IMPROPER RESULT FROM 'DELTA");
END IF;
VAL := FIX'FORE;
VAL := FIX'AFT;
END P;
USE P;
BEGIN
RESULT;
END C74004A;
| 26.385638 | 79 | 0.495414 | false | false | true |
5,895 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C45531B.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT THE OPERATOR "/" PRODUCES CORRECT RESULTS
-- FOR MIXED FIXED POINT AND INTEGER TYPES USING 3 SUBTESTS.
-- THIS TEST REQUIRES MIN_WORD_LENGTH = 12.
-- THIS TEST USES VALUES OF DELTA WHICH ARE LESS THAN 0.5.
--
-- TEST CASES ARE:
-- A) FIXED / INTEGER WHEN ALL VALUES ARE MODEL NUMBERS.
-- B) FIXED / INTEGER WITH NUMERATOR MODEL NUMBER AND RESULT NOT.
-- C) FIXED / INTEGER FOR NON-MODEL NUMBERS.
--
-- REPEAT FOR MINIMUM REQUIRED WORD LENGTHS OF 12, 16, 32 AND 48,
-- WITH RANGE <, =, AND > THAN 1.0 AND
-- WITH DELTA <, =, AND > THAN 1.0.
-- HISTORY:
-- NTW 09/08/86 CREATED ORIGINAL TEST.
-- RJW 11/05/86 REVISED COMMENTS.
-- DHH 01/13/88 ADDED APPLICABILITY CRITERIA AND STANDARD HEADER.
-- BCB 04/27/90 REVISED APPLICABILITY CRITERIA.
-- BCB 10/03/90 REMOVED APPLICABILITY CRITERIA AND N/A => ERROR
-- LINE. CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
WITH REPORT;
PROCEDURE C45531B IS
USE REPORT;
MIN_WORD_LENGTH : CONSTANT := 12;
FULL_SCALE : CONSTANT := 2 ** (MIN_WORD_LENGTH - 1);
FORTH : CONSTANT := FULL_SCALE / 4;
DEL1 : CONSTANT := 0.5 / FULL_SCALE;
DEL2 : CONSTANT := 2.0 * DEL1;
DEL4 : CONSTANT := 4.0 * DEL1;
TYPE FX_0P5 IS DELTA DEL1 * 1 RANGE -0.5 .. 0.5 - DEL1 * 1;
TYPE FX_1 IS DELTA DEL1 * 2 RANGE -1.0 .. 1.0 - DEL1 * 2;
TYPE FX_2 IS DELTA DEL1 * 4 RANGE -2.0 .. 2.0 - DEL1 * 4;
BEGIN TEST ("C45531B", "MIXED FIXED POINT AND INTEGER ""/"" "
& "FOR RANGE <, =, > 1.0");
--------------------------------------------------
-- CASE A) FIXED / INTEGER WHEN ALL VALUES ARE MODEL NUMBERS.
A: DECLARE
A : FX_0P5 := 0.0;
B : INTEGER := 0;
RESULT_VALUE : FX_0P5 := 0.0;
LOWEST_ACCEPTABLE_VALUE : FX_0P5 := FX_0P5 (3 * DEL1);
HIGHEST_ACCEPTABLE_VALUE : FX_0P5 := FX_0P5 (3 * DEL1);
BEGIN
IF EQUAL (3, 3) THEN
A := FX_0P5 (15 * DEL1); -- A MODEL NUMBER
B := 5;
END IF;
RESULT_VALUE := A / B;
IF (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
FAILED ("RESULT OF ""/"" OUTSIDE RESULT MODEL INTERVAL "
& "FOR FIXED / INTEGER "
& "WHEN ALL VALUES ARE MODEL NUMBERS");
END IF;
END A;
--------------------------------------------------
-- CASE B) FIXED / INTEGER WITH NUMERATOR MODEL NUMBER, RESULT NOT
B: DECLARE
A : FX_1 := 0.0;
B : INTEGER := 0;
RESULT_VALUE : FX_1 := 0.0;
LOWEST_ACCEPTABLE_VALUE : FX_1
:= FX_1 (DEL2 * FORTH );
HIGHEST_ACCEPTABLE_VALUE : FX_1
:= FX_1 (DEL2 * (FORTH + 1) );
BEGIN
IF EQUAL (3, 3) THEN -- A IS A MODEL NUMBER
A := FX_1 (DEL2 * (3 * FORTH + 1) );
B := 3;
END IF;
RESULT_VALUE := A / B;
IF (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
FAILED ("RESULT OF ""/"" OUTSIDE RESULT MODEL INTERVAL "
& "FOR FIXED / INTEGER WITH NUMERATOR MODEL "
& "NUMBER, RESULT NOT");
END IF;
END B;
--------------------------------------------------
-- CASE C) FIXED / INTEGER FOR NON-MODEL NUMBERS
C: DECLARE
A : FX_2 := 0.0;
B : INTEGER := 0;
RESULT_VALUE : FX_2 := 0.0;
LOWEST_ACCEPTABLE_VALUE : FX_2
:= FX_2 (DEL4 * FORTH );
HIGHEST_ACCEPTABLE_VALUE : FX_2
:= FX_2 (DEL4 * (FORTH + 1) );
BEGIN
IF EQUAL (3, 3) THEN -- A NOT MODEL NUMBER
A := FX_2 (3 * (DEL4 * FORTH + DEL1) );
B := 3;
END IF;
RESULT_VALUE := A / B;
IF (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
FAILED ("RESULT OF ""/"" OUTSIDE RESULT MODEL INTERVAL "
& "FOR FIXED / INTEGER FOR NON-MODEL NUMBERS");
END IF;
END C;
--------------------------------------------------
RESULT;
END C45531B;
| 38.279221 | 79 | 0.516709 | false | false | true |
90 | ada | Ada | [
"Info-ZIP"
] | 1 | for Value in 0..Integer'Last loop
Put (Value);
exit when Value mod 6 = 0;
end loop;
| 18 | 33 | 0.655556 | false | false | true |
2,875 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Calendar;
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Integer_Text_IO;
with Ada.Text_IO;
procedure Date_Manipulation is
type Month_Name_T is
(January, February, March, April, May, June,
July, August, September, October, November, December);
type Time_Zone_Name_T is (EST, Lisbon);
type Period_T is (AM, PM);
package TZ renames Ada.Calendar.Time_Zones;
use type TZ.Time_Offset;
Time_Zone_Offset : array (Time_Zone_Name_T) of TZ.Time_Offset :=
(EST => -5 * 60,
Lisbon => 0);
Period_Offset : array (Period_T) of Natural :=
(AM => 0,
PM => 12);
package Month_Name_IO is
new Ada.Text_IO.Enumeration_IO (Month_Name_T);
package Time_Zone_Name_IO is
new Ada.Text_IO.Enumeration_IO (Time_Zone_Name_T);
package Period_IO is
new Ada.Text_IO.Enumeration_IO (Period_T);
package Std renames Ada.Calendar;
use type Std.Time;
package Fmt renames Std.Formatting;
function To_Number (Name : Month_Name_T) return Std.Month_Number is
begin
return Std.Month_Number (Month_Name_T'Pos (Name) + 1);
end;
function To_Time (S : String) return Std.Time is
Month : Month_Name_T;
Day : Std.Day_Number;
Year : Std.Year_Number;
Hour : Fmt.Hour_Number;
Minute : Fmt.Minute_Number;
Period : Period_T;
Time_Zone : Time_Zone_Name_T;
I : Natural;
begin
Month_Name_IO.Get
(From => S, Item => Month, Last => I);
Ada.Integer_Text_IO.Get
(From => S (I + 1 .. S'Last), Item => Day, Last => I);
Ada.Integer_Text_IO.Get
(From => S (I + 1 .. S'Last), Item => Year, Last => I);
Ada.Integer_Text_IO.Get
(From => S (I + 1 .. S'Last), Item => Hour, Last => I);
Ada.Integer_Text_IO.Get
(From => S (I + 2 .. S'Last), Item => Minute, Last => I);
-- here we start 2 chars down to skip the ':'
Period_IO.Get
(From => S (I + 1 .. S'Last), Item => Period, Last => I);
Time_Zone_Name_IO.Get
(From => S (I + 1 .. S'Last), Item => Time_Zone, Last => I);
return Fmt.Time_Of
(Year => Year,
Month => To_Number (Month),
Day => Day,
Hour => Hour + Period_Offset (Period),
Minute => Minute,
Second => 0,
Time_Zone => Time_Zone_Offset (Time_Zone));
end;
function Img
(Date : Std.Time; Zone : Time_Zone_Name_T) return String is
begin
return
Fmt.Image (Date => Date, Time_Zone => Time_Zone_Offset (Zone)) &
" " & Time_Zone_Name_T'Image (Zone);
end;
T1, T2 : Std.Time;
use Ada.Text_IO;
begin
T1 := To_Time ("March 7 2009 7:30pm EST");
T2 := T1 + 12.0 * 60.0 * 60.0;
Put_Line ("T1 => " & Img (T1, EST) & " = " & Img (T1, Lisbon));
Put_Line ("T2 => " & Img (T2, EST) & " = " & Img (T2, Lisbon));
end;
| 29.336735 | 73 | 0.596522 | false | false | true |
242 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Characters.Handling, Ada.Text_IO;
use Ada.Characters.Handling, Ada.Text_IO;
procedure Upper_Case_String is
S : constant String := "alphaBETA";
begin
Put_Line (To_Upper (S));
Put_Line (To_Lower (S));
end Upper_Case_String;
| 24.2 | 42 | 0.743802 | false | false | true |
2,599 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C66002G.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT OVERLOADED SUBPROGRAM DECLARATIONS
-- ARE PERMITTED IN WHICH THERE IS A MINIMAL
-- DIFFERENCE BETWEEN THE DECLARATIONS.
-- (G) THE RESULT TYPE OF TWO FUNCTION DECLARATIONS IS DIFFERENT.
-- CVP 5/4/81
-- JRK 5/8/81
-- NL 10/13/81
-- SPS 10/26/82
WITH REPORT;
PROCEDURE C66002G IS
USE REPORT;
BEGIN
TEST ("C66002G", "SUBPROGRAM OVERLOADING WITH " &
"MINIMAL DIFFERENCES ALLOWED");
--------------------------------------------------
-- THE RESULT TYPES OF TWO FUNCTION
-- DECLARATIONS ARE DIFFERENT.
DECLARE
I : INTEGER;
B : BOOLEAN;
S : STRING (1..2) := "12";
FUNCTION F RETURN INTEGER IS
BEGIN
S(1) := 'A';
RETURN IDENT_INT (0); -- THIS VALUE IS IRRELEVENT.
END F;
FUNCTION F RETURN BOOLEAN IS
BEGIN
S(2) := 'B';
RETURN IDENT_BOOL (TRUE); -- THIS VALUE IS IRRELEVANT.
END F;
BEGIN
I := F;
B := F;
IF S /= "AB" THEN
FAILED ("FUNCTIONS DIFFERING ONLY IN " &
"BASE TYPE OF RETURNED VALUE " &
"CAUSED CONFUSION");
END IF;
END;
--------------------------------------------------
RESULT;
END C66002G;
| 31.313253 | 79 | 0.572913 | false | false | true |
2,052 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Text_IO;
procedure Vignere_Cipher is
subtype Letter is Character range 'A' .. 'Z';
subtype Lowercase is Character range 'a' .. 'z';
function "+"(X, Y: Letter) return Letter is
begin
return Character'Val( ( (Character'Pos(X)-Character'Pos('A'))
+ (Character'Pos(Y)-Character'Pos('A')) ) mod 26
+ Character'Pos('A'));
end;
function Normalize(S: String) return String is
-- removes all characters except for uppercase and lowercase letters
-- replaces lowercase by uppercase letters
Offset: Integer := Character'Pos('A') - Character'Pos('a');
begin
if S="" then
return "";
elsif S(S'First) in Letter then
return S(S'First) & Normalize(S(S'First+1 .. S'Last));
elsif S(S'First) in Lowercase then
return (Character'Val(Character'Pos(S(S'First)) + Offset)
& Normalize(S(S'First+1 .. S'Last)));
else
return Normalize(S(S'First+1 .. S'Last));
end if;
end Normalize;
function Encrypt(Key: String; Text: String) return String is
Ciphertext: String(Text'Range);
begin
for I in Text'Range loop
Ciphertext(I) := Text(I)
+ Key(Key'First + ((I-Text'First) mod Key'Length));
end loop;
return Ciphertext;
end Encrypt;
function Invert(Key: String) return String is
Result: String(Key'Range);
begin
for I in Key'Range loop
Result(I)
:= Character'Val( 26 - (Character'Pos(Key(I))-Character'Pos('A'))
+ Character'Pos('A') );
end loop;
return Result;
end Invert;
use Ada.Text_IO;
Input: String := Get_Line;
Key: String := Normalize(Get_Line);
Ciph: String := Encrypt(Key => Key, Text => Normalize(Input));
begin
Put_Line("Input =" & Input);
Put_Line("Key =" & Key);
Put_Line("Ciphertext =" & Ciph);
Put_Line("Decryption =" & Encrypt(Key => Invert(Key), Text => Ciph));
end Vignere_Cipher;
| 32.0625 | 80 | 0.57846 | false | false | true |
5,117 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C37209A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS NOT RAISED FOR A CONSTANT OBJECT
-- DECLARATION WHOSE SUBTYPE INDICATION SPECIFIES AN UNCONSTRAINED
-- TYPE WITH DEFAULT DISCRIMINANT VALUES AND WHOSE INITIALIZATION
-- EXPRESSION SPECIFIES A VALUE WHOSE DISCRIMINANTS ARE NOT EQUAL TO
-- THE DEFAULT VALUE.
-- R.WILLIAMS 8/25/86
WITH REPORT; USE REPORT;
PROCEDURE C37209A IS
BEGIN
TEST ( "C37209A", "CHECK THAT CONSTRAINT_ERROR IS NOT RAISED " &
"FOR A CONSTANT OBJECT DECLARATION WHOSE " &
"SUBTYPE INDICATION SPECIFIES AN " &
"UNCONSTRAINED TYPE WITH DEFAULT " &
"DISCRIMINANT VALUES AND WHOSE " &
"INITIALIZATION EXPRESSION SPECIFIES A VALUE " &
"WHOSE DISCRIMINANTS ARE NOT EQUAL TO THE " &
"DEFAULT VALUE" );
DECLARE
TYPE REC1 (D : INTEGER := IDENT_INT (5)) IS
RECORD
NULL;
END RECORD;
BEGIN
DECLARE
R1 : CONSTANT REC1 := (D => IDENT_INT (10));
BEGIN
COMMENT ( "NO EXCEPTION RAISED AT DECLARATION OF R1" );
EXCEPTION
WHEN OTHERS =>
FAILED ( "EXCEPTION FOR R1 RAISED INSIDE BLOCK" );
END;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED AT DECLARATION OF " &
"R1" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED AT DECLARATION OF " &
"R1" );
END;
BEGIN
DECLARE
PACKAGE PRIV IS
TYPE REC2 (D : INTEGER:= IDENT_INT (5)) IS PRIVATE;
R2 : CONSTANT REC2;
PRIVATE
TYPE REC2 (D : INTEGER := IDENT_INT (5)) IS
RECORD
NULL;
END RECORD;
R2 : CONSTANT REC2 := (D => IDENT_INT (10));
END PRIV;
USE PRIV;
BEGIN
DECLARE
I : INTEGER := R2.D;
BEGIN
COMMENT ( "NO EXCEPTION RAISED AT DECLARATION " &
"OF R2" );
END;
END;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED AT DECLARATION OF " &
"R2" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED AT DECLARATION " &
"OF R2" );
END;
BEGIN
DECLARE
PACKAGE LPRIV IS
TYPE REC3 (D : INTEGER:= IDENT_INT (5)) IS
LIMITED PRIVATE;
R3 : CONSTANT REC3;
PRIVATE
TYPE REC3 (D : INTEGER := IDENT_INT (5)) IS
RECORD
NULL;
END RECORD;
R3 : CONSTANT REC3 := (D => IDENT_INT (10));
END LPRIV;
USE LPRIV;
BEGIN
DECLARE
I : INTEGER;
BEGIN
I := R3.D;
COMMENT ( "NO EXCEPTION RAISED AT DECLARATION " &
"OF R3" );
END;
END;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED AT DECLARATION OF " &
"R3" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED AT DECLARATION " &
"OF R3" );
END;
RESULT;
END C37209A;
| 35.047945 | 79 | 0.487395 | false | false | true |
3,608 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C32001D.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT IN MULTIPLE OBJECT DECLARATIONS FOR ACCESS TYPES, THE
-- SUBTYPE INDICATION AND THE INITIALIZATION EXPRESSIONS ARE EVALUATED
-- ONCE FOR EACH NAMED OBJECT THAT IS DECLARED AND THE SUBTYPE
-- INDICATION IS EVALUATED FIRST. ALSO, CHECK THAT THE EVALUATIONS
-- YIELD THE SAME RESULT AS A SEQUENCE OF SINGLE OBJECT DECLARATIONS.
-- RJW 7/16/86
WITH REPORT; USE REPORT;
PROCEDURE C32001D IS
TYPE ARR IS ARRAY (1 .. 2) OF INTEGER;
BUMP : ARR := (0, 0);
F1 : ARR;
FUNCTION F (I : INTEGER) RETURN INTEGER IS
BEGIN
BUMP (I) := BUMP (I) + 1;
F1 (I) := BUMP (I);
RETURN BUMP (I);
END F;
FUNCTION G (I : INTEGER) RETURN INTEGER IS
BEGIN
BUMP (I) := BUMP (I) + 1;
RETURN BUMP (I);
END G;
BEGIN
TEST ("C32001D", "CHECK THAT IN MULTIPLE OBJECT DECLARATIONS " &
"FOR ACCESS TYPES, THE SUBTYPE INDICATION " &
"AND THE INITIALIZATION EXPRESSIONS ARE " &
"EVALUATED ONCE FOR EACH NAMED OBJECT THAT " &
"IS DECLARED AND THE SUBTYPE INDICATION IS " &
"EVALUATED FIRST. ALSO, CHECK THAT THE " &
"EVALUATIONS YIELD THE SAME RESULT AS A " &
"SEQUENCE OF SINGLE OBJECT DECLARATIONS" );
DECLARE
TYPE CELL (SIZE : INTEGER) IS
RECORD
VALUE : INTEGER;
END RECORD;
TYPE LINK IS ACCESS CELL;
L1, L2 : LINK (F (1)) := NEW CELL'(F1 (1), G (1));
CL1, CL2 : CONSTANT LINK (F (2)) := NEW CELL'(F1 (2), G (2));
PROCEDURE CHECK (L : LINK; V1, V2 : INTEGER; S : STRING) IS
BEGIN
IF L.SIZE /= V1 THEN
FAILED ( S & ".SIZE INITIALIZED INCORRECTLY TO " &
INTEGER'IMAGE (L.SIZE));
END IF;
IF L.VALUE /= V2 THEN
FAILED ( S & ".VALUE INITIALIZED INCORRECTLY TO " &
INTEGER'IMAGE (L.VALUE));
END IF;
END CHECK;
BEGIN
CHECK (L1, 1, 2, "L1");
CHECK (L2, 3, 4, "L2");
CHECK (CL1, 1, 2, "CL1");
CHECK (CL2, 3, 4, "CL2");
END;
RESULT;
END C32001D;
| 36.08 | 79 | 0.561253 | false | false | true |
1,381 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CA1013A5.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- WKB 7/20/81
-- JBG 9/15/83
WITH CA1013A2;
PRAGMA ELABORATE (CA1013A2);
FUNCTION CA1013A5 IS NEW CA1013A2 (INTEGER);
| 44.548387 | 79 | 0.68139 | false | false | true |
2,662 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C9A003A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT ABORTING A TERMINATED TASK DOES NOT CAUSE EXCEPTIONS.
-- RM 5/21/82
-- SPS 11/21/82
-- PWN 09/11/94 REMOVED PRAGMA PRIORITY FOR ADA 9X
with Impdef;
WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;
PROCEDURE C9A003A IS
-- THE TASK WILL HAVE HIGHER PRIORITY ( PRIORITY'LAST )
BEGIN
-------------------------------------------------------------------
TEST ("C9A003A", "CHECK THAT ABORTING A TERMINATED TASK" &
" DOES NOT CAUSE EXCEPTIONS" );
DECLARE
TASK TYPE T_TYPE IS
ENTRY E ;
END T_TYPE ;
T_OBJECT1 : T_TYPE ;
TASK BODY T_TYPE IS
BUSY : BOOLEAN := FALSE ;
BEGIN
NULL;
END T_TYPE ;
BEGIN
IF NOT T_OBJECT1'TERMINATED THEN
DELAY 20.0 * Impdef.One_Second;
END IF;
IF NOT T_OBJECT1'TERMINATED THEN
COMMENT( "TASK NOT YET TERMINATED (AFTER 20 S.)" );
END IF;
BEGIN
ABORT T_OBJECT1 ;
EXCEPTION
WHEN OTHERS =>
FAILED( "EXCEPTION RAISED (WHEN ABORTING A" &
" TERMINATED TASK)" );
END ;
END ;
-------------------------------------------------------------------
RESULT;
END C9A003A ;
| 25.113208 | 79 | 0.555597 | false | false | true |
9,994 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CC3019C1.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- THIS IS GENERIC PACKAGE WHICH IS USED TO CHECK THE LEVEL OF
-- NESTED GENERICS SUPPORTED BY AN IMPLEMENTATION. IT IS USED
-- BY MAIN PROCEDURE CC3019C2M.ADA.
--
-- HISTORY:
-- EDWARD V. BERARD, 31 AUGUST 1990
WITH CC3019C0_LIST_CLASS ;
GENERIC
TYPE ELEMENT IS LIMITED PRIVATE ;
WITH PROCEDURE ASSIGN (SOURCE : IN OUT ELEMENT ;
DESTINATION : IN OUT ELEMENT) ;
WITH FUNCTION "=" (LEFT : IN ELEMENT ;
RIGHT : IN ELEMENT) RETURN BOOLEAN ;
PACKAGE CC3019C1_NESTED_GENERICS IS
TYPE NESTED_GENERICS_TYPE IS LIMITED PRIVATE ;
PROCEDURE COPY (SOURCE : IN OUT NESTED_GENERICS_TYPE ;
DESTINATION : IN OUT NESTED_GENERICS_TYPE) ;
PROCEDURE SET_ELEMENT
(FOR_THIS_NGT_OBJECT : IN OUT NESTED_GENERICS_TYPE ;
TO_THIS_ELEMENT : IN OUT ELEMENT) ;
PROCEDURE SET_NUMBER
(FOR_THIS_NGT_OBJECT : IN OUT NESTED_GENERICS_TYPE ;
TO_THIS_NUMBER : IN NATURAL) ;
FUNCTION "=" (LEFT : IN NESTED_GENERICS_TYPE ;
RIGHT : IN NESTED_GENERICS_TYPE) RETURN BOOLEAN ;
FUNCTION ELEMENT_OF (THIS_NGT_OBJECT : IN NESTED_GENERICS_TYPE)
RETURN ELEMENT ;
FUNCTION NUMBER_OF (THIS_NGT_OBJECT : IN NESTED_GENERICS_TYPE)
RETURN NATURAL ;
GENERIC
TYPE ELEMENT IS LIMITED PRIVATE ;
WITH PROCEDURE ASSIGN (SOURCE : IN OUT ELEMENT ;
DESTINATION : IN OUT ELEMENT) ;
PACKAGE GENERIC_TASK IS
TASK TYPE PROTECTED_AREA IS
ENTRY STORE (ITEM : IN OUT ELEMENT) ;
ENTRY GET (ITEM : IN OUT ELEMENT) ;
END PROTECTED_AREA ;
END GENERIC_TASK ;
GENERIC
TYPE ELEMENT IS LIMITED PRIVATE ;
WITH PROCEDURE ASSIGN (SOURCE : IN OUT ELEMENT ;
DESTINATION : IN OUT ELEMENT) ;
WITH FUNCTION "=" (LEFT : IN ELEMENT ;
RIGHT : IN ELEMENT) RETURN BOOLEAN ;
PACKAGE STACK_CLASS IS
TYPE STACK IS LIMITED PRIVATE ;
OVERFLOW : EXCEPTION ;
UNDERFLOW : EXCEPTION ;
PROCEDURE PUSH (THIS_ELEMENT : IN OUT ELEMENT ;
ON_TO_THIS_STACK : IN OUT STACK) ;
PROCEDURE POP (THIS_ELEMENT : IN OUT ELEMENT ;
OFF_THIS_STACK : IN OUT STACK) ;
PROCEDURE COPY (THIS_STACK : IN OUT STACK ;
TO_THIS_STACK : IN OUT STACK) ;
PROCEDURE CLEAR (THIS_STACK : IN OUT STACK) ;
GENERIC
WITH PROCEDURE PROCESS (THIS_ELEMENT : IN ELEMENT ;
CONTINUE : OUT BOOLEAN) ;
PROCEDURE ITERATE (OVER_THIS_STACK : IN STACK) ;
FUNCTION NUMBER_OF_ELEMENTS (ON_THIS_STACK : IN STACK)
RETURN NATURAL ;
FUNCTION "=" (LEFT : IN STACK ;
RIGHT : IN STACK) RETURN BOOLEAN ;
PRIVATE
PACKAGE NEW_LIST_CLASS IS NEW
CC3019C0_LIST_CLASS (ELEMENT => ELEMENT,
ASSIGN => ASSIGN,
"=" => "=") ;
TYPE STACK IS NEW NEW_LIST_CLASS.LIST ;
END STACK_CLASS ;
PRIVATE
TYPE NESTED_GENERICS_TYPE IS RECORD
FIRST : ELEMENT ;
SECOND : NATURAL ;
END RECORD ;
END CC3019C1_NESTED_GENERICS ;
PACKAGE BODY CC3019C1_NESTED_GENERICS IS
PROCEDURE COPY (SOURCE : IN OUT NESTED_GENERICS_TYPE ;
DESTINATION : IN OUT NESTED_GENERICS_TYPE) IS
BEGIN -- COPY
ASSIGN (SOURCE => SOURCE.FIRST,
DESTINATION => DESTINATION.FIRST) ;
DESTINATION.SECOND := SOURCE.SECOND ;
END COPY ;
PROCEDURE SET_ELEMENT
(FOR_THIS_NGT_OBJECT : IN OUT NESTED_GENERICS_TYPE ;
TO_THIS_ELEMENT : IN OUT ELEMENT) IS
BEGIN -- SET_ELEMENT
ASSIGN (SOURCE => TO_THIS_ELEMENT,
DESTINATION => FOR_THIS_NGT_OBJECT.FIRST) ;
END SET_ELEMENT ;
PROCEDURE SET_NUMBER
(FOR_THIS_NGT_OBJECT : IN OUT NESTED_GENERICS_TYPE ;
TO_THIS_NUMBER : IN NATURAL) IS
BEGIN -- SET_NUMBER
FOR_THIS_NGT_OBJECT.SECOND := TO_THIS_NUMBER ;
END SET_NUMBER ;
FUNCTION "=" (LEFT : IN NESTED_GENERICS_TYPE ;
RIGHT : IN NESTED_GENERICS_TYPE) RETURN BOOLEAN IS
BEGIN -- "="
IF (LEFT.FIRST = RIGHT.FIRST) AND
(LEFT.SECOND = RIGHT.SECOND) THEN
RETURN TRUE ;
ELSE
RETURN FALSE ;
END IF ;
END "=" ;
FUNCTION ELEMENT_OF (THIS_NGT_OBJECT : IN NESTED_GENERICS_TYPE)
RETURN ELEMENT IS
BEGIN -- ELEMENT_OF
RETURN THIS_NGT_OBJECT.FIRST ;
END ELEMENT_OF ;
FUNCTION NUMBER_OF (THIS_NGT_OBJECT : IN NESTED_GENERICS_TYPE)
RETURN NATURAL IS
BEGIN -- NUMBER_OF
RETURN THIS_NGT_OBJECT.SECOND ;
END NUMBER_OF ;
PACKAGE BODY GENERIC_TASK IS
TASK BODY PROTECTED_AREA IS
LOCAL_STORE : ELEMENT ;
BEGIN -- PROTECTED_AREA
LOOP
SELECT
ACCEPT STORE (ITEM : IN OUT ELEMENT) DO
ASSIGN (SOURCE => ITEM,
DESTINATION => LOCAL_STORE) ;
END STORE ;
OR
ACCEPT GET (ITEM : IN OUT ELEMENT) DO
ASSIGN (SOURCE => LOCAL_STORE,
DESTINATION => ITEM) ;
END GET ;
OR
TERMINATE ;
END SELECT ;
END LOOP ;
END PROTECTED_AREA ;
END GENERIC_TASK ;
PACKAGE BODY STACK_CLASS IS
PROCEDURE PUSH (THIS_ELEMENT : IN OUT ELEMENT ;
ON_TO_THIS_STACK : IN OUT STACK) IS
BEGIN -- PUSH
NEW_LIST_CLASS.ADD (
THIS_ELEMENT => THIS_ELEMENT,
TO_THIS_LIST =>
NEW_LIST_CLASS.LIST (ON_TO_THIS_STACK)) ;
EXCEPTION
WHEN NEW_LIST_CLASS.OVERFLOW => RAISE OVERFLOW ;
END PUSH ;
PROCEDURE POP (THIS_ELEMENT : IN OUT ELEMENT ;
OFF_THIS_STACK : IN OUT STACK) IS
BEGIN -- POP
NEW_LIST_CLASS.DELETE (
THIS_ELEMENT => THIS_ELEMENT,
FROM_THIS_LIST =>
NEW_LIST_CLASS.LIST (OFF_THIS_STACK)) ;
EXCEPTION
WHEN NEW_LIST_CLASS.UNDERFLOW => RAISE UNDERFLOW ;
END POP ;
PROCEDURE COPY (THIS_STACK : IN OUT STACK ;
TO_THIS_STACK : IN OUT STACK) IS
BEGIN -- COPY
NEW_LIST_CLASS.COPY (
THIS_LIST => NEW_LIST_CLASS.LIST (THIS_STACK),
TO_THIS_LIST =>
NEW_LIST_CLASS.LIST (TO_THIS_STACK)) ;
END COPY ;
PROCEDURE CLEAR (THIS_STACK : IN OUT STACK) IS
BEGIN -- CLEAR
NEW_LIST_CLASS.CLEAR (NEW_LIST_CLASS.LIST (THIS_STACK)) ;
END CLEAR ;
PROCEDURE ITERATE (OVER_THIS_STACK : IN STACK) IS
PROCEDURE STACK_ITERATE IS NEW NEW_LIST_CLASS.ITERATE
(PROCESS => PROCESS) ;
BEGIN -- ITERATE
STACK_ITERATE (NEW_LIST_CLASS.LIST (OVER_THIS_STACK)) ;
END ITERATE ;
FUNCTION NUMBER_OF_ELEMENTS (ON_THIS_STACK : IN STACK)
RETURN NATURAL IS
BEGIN -- NUMBER_OF_ELEMENTS
RETURN NEW_LIST_CLASS.NUMBER_OF_ELEMENTS
(IN_THIS_LIST =>
NEW_LIST_CLASS.LIST (ON_THIS_STACK)) ;
END NUMBER_OF_ELEMENTS ;
FUNCTION "=" (LEFT : IN STACK ;
RIGHT : IN STACK) RETURN BOOLEAN IS
BEGIN -- "="
RETURN NEW_LIST_CLASS."=" (
LEFT => NEW_LIST_CLASS.LIST (LEFT),
RIGHT => NEW_LIST_CLASS.LIST (RIGHT)) ;
END "=" ;
END STACK_CLASS ;
END CC3019C1_NESTED_GENERICS ;
| 30.10241 | 79 | 0.53322 | false | false | true |
274 | ada | Ada | [
"Info-ZIP"
] | 1 | generic
type Swap_Type is private; -- Generic parameter
procedure Generic_Swap (Left, Right : in out Swap_Type);
procedure Generic_Swap (Left, Right : in out Swap_Type) is
Temp : constant Swap_Type := Left;
begin
Left := Right;
Right := Temp;
end Generic_Swap;
| 24.909091 | 58 | 0.722628 | false | false | true |
1,765 | ada | Ada | [
"Info-ZIP"
] | 1 | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursive_Binary_Search is
Not_Found : exception;
generic
type Index is range <>;
type Element is private;
type Array_Of_Elements is array (Index range <>) of Element;
with function "<" (L, R : Element) return Boolean is <>;
function Search (Container : Array_Of_Elements; Value : Element) return Index;
function Search (Container : Array_Of_Elements; Value : Element) return Index is
Mid : Index;
begin
if Container'Length > 0 then
Mid := (Container'First + Container'Last) / 2;
if Value < Container (Mid) then
if Container'First /= Mid then
return Search (Container (Container'First..Mid - 1), Value);
end if;
elsif Container (Mid) < Value then
if Container'Last /= Mid then
return Search (Container (Mid + 1..Container'Last), Value);
end if;
else
return Mid;
end if;
end if;
raise Not_Found;
end Search;
type Integer_Array is array (Positive range <>) of Integer;
function Find is new Search (Positive, Integer, Integer_Array);
procedure Test (X : Integer_Array; E : Integer) is
begin
New_Line;
for I in X'Range loop
Put (Integer'Image (X (I)));
end loop;
Put (" contains" & Integer'Image (E) & " at" & Integer'Image (Find (X, E)));
exception
when Not_Found =>
Put (" does not contain" & Integer'Image (E));
end Test;
begin
Test ((2, 4, 6, 8, 9), 2);
Test ((2, 4, 6, 8, 9), 1);
Test ((2, 4, 6, 8, 9), 8);
Test ((2, 4, 6, 8, 9), 10);
Test ((2, 4, 6, 8, 9), 9);
Test ((2, 4, 6, 8, 9), 5);
end Test_Recursive_Binary_Search;
| 32.090909 | 83 | 0.582436 | false | false | true |
176 | ada | Ada | [
"Info-ZIP"
] | 1 | package Synchronous_Concurrent is
task Printer is
entry Put(Item : in String);
entry Get_Count(Count : out Natural);
end Printer;
end Synchronous_Concurrent;
| 25.142857 | 43 | 0.727273 | false | false | true |
4,637 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C37208B.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- FOR A TYPE WITH DEFAULT DISCRIMINANT VALUES, CHECK THAT A
-- DISCRIMINANT CONSTRAINT CAN BE OMITTED IN A GENERIC FORMAL
-- PARAMETER, AND HENCE, FOR BOTH IN AND IN OUT PARAMETERS, THE
-- 'CONSTRAINED ATTRIBUTE OF THE ACTUAL PARAMETER BECOMES THE
-- 'CONSTRAINED ATTRIBUTE OF THE FORMAL PARAMETER, AND, FOR IN
-- OUT PARAMETERS, IF THE 'CONSTRAINED ATTRIBUTE IS FALSE,
-- ASSIGNMENTS TO THE FORMAL PARAMETERS CAN CHANGE THE
-- DISCRIMINANTS OF THE ACTUAL PARAMETER; IF THE 'CONSTRAINED
-- ATTRIBUTE IS TRUE, ASSIGNMENTS THAT ATTEMPT TO CHANGE THE
-- DISCRIMINANTS OF THE ACTUAL PARAMETER RAISE CONSTRAINT_ERROR.
-- ASL 7/29/81
-- VKG 1/20/83
-- EDS 7/16/98 AVOID OPTIMIZATION
WITH REPORT;
PROCEDURE C37208B IS
USE REPORT;
BEGIN
TEST ("C37208B","FOR TYPES WITH DEFAULT DISCRIMINANT " &
"VALUES, DISCRIMINANT CONSTRAINTS CAN BE OMITTED " &
"IN GENERIC FORMAL PARAMETERS, AND THE " &
"'CONSTRAINED ATTRIBUTE HAS CORRECT VALUES " &
"DEPENDING ON THE ACTUAL PARAMETERS");
DECLARE
TYPE REC(DISC : INTEGER := 7) IS
RECORD
NULL;
END RECORD;
KC : CONSTANT REC(3) := (DISC => 3);
KU : CONSTANT REC := (DISC => 3);
OBJC1,OBJC2 : REC(3) := (DISC => 3);
OBJU1,OBJU2 : REC := (DISC => 3);
GENERIC
P_IN1 : REC;
P_IN2 : REC;
P_IN_OUT : IN OUT REC;
STATUS : BOOLEAN;
PROCEDURE PROC;
PROCEDURE PROC IS
BEGIN
IF P_IN1'CONSTRAINED /= TRUE OR
P_IN2'CONSTRAINED /= TRUE OR
P_IN_OUT'CONSTRAINED /= STATUS
THEN
FAILED ("'CONSTRAINED ATTRIBUTES DO NOT MATCH " &
"FOR ACTUAL AND FORMAL PARAMETERS");
END IF;
IF NOT STATUS THEN
BEGIN
P_IN_OUT := (DISC => IDENT_INT(7));
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED " &
"WHEN TRYING TO " &
"CHANGE UNCONSTRAINED " &
"DISCRIMINANT VALUE");
END;
ELSE
BEGIN
P_IN_OUT := (DISC => IDENT_INT(7));
FAILED ("DISCRIMINANT OF CONSTRAINED " &
"ACTUAL PARAMETER ILLEGALLY " &
"CHANGED BY ASSIGNMENT");
EXCEPTION
WHEN CONSTRAINT_ERROR => NULL;
WHEN OTHERS => FAILED ("WRONG EXCEPTION");
END;
END IF;
END PROC;
BEGIN
DECLARE
PROCEDURE PROC_C IS NEW PROC(KC,OBJC1,OBJC2,IDENT_BOOL(TRUE));
PROCEDURE PROC_U IS NEW PROC(KU,OBJU1,OBJU2,IDENT_BOOL(FALSE));
BEGIN
PROC_C;
PROC_U;
IF OBJU2.DISC /= 7 THEN
FAILED ("ASSIGNMENT TO UNCONSTRAINED ACTUAL " &
"PARAMETER FAILED TO CHANGE DISCRIMINANT ");
END IF;
END;
END;
RESULT;
END C37208B;
| 38.322314 | 79 | 0.541298 | false | false | true |
2,651 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C64202A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT THE DEFAULT EXPRESSIONS OF FORMAL PARAMETERS ARE EVALUATED
-- EACH TIME THEY ARE NEEDED.
-- SPS 2/22/84
WITH REPORT; USE REPORT;
PROCEDURE C64202A IS
BEGIN
TEST ("C64202A", "CHECK THAT THE DEFAULT EXPRESSION IS EVALUATED" &
" EACH TIME IT IS NEEDED");
DECLARE
X : INTEGER := 1;
FUNCTION F RETURN INTEGER IS
BEGIN
X := X + 1;
RETURN X;
END F;
PROCEDURE P (CALL : POSITIVE; X, Y : INTEGER := F) IS
BEGIN
IF CALL = 1 THEN
IF X = Y OR Y /= 2 THEN
FAILED ("DEFAULT NOT EVALUATED CORRECTLY - 1" &
" X =" & INTEGER'IMAGE(X) & " Y =" &
INTEGER'IMAGE(Y));
END IF;
ELSIF CALL = 2 THEN
IF X = Y OR
NOT ((X = 3 AND Y = 4) OR (X = 4 AND Y = 3)) THEN
FAILED ("DEFAULT NOT EVALUATED CORRECTLY - 2" &
" X =" & INTEGER'IMAGE(X) & " Y =" &
INTEGER'IMAGE(Y));
END IF;
END IF;
END P;
BEGIN
COMMENT ("FIRST CALL");
P (1, 3);
COMMENT ("SECOND CALL");
P(2);
END;
RESULT;
END C64202A;
| 36.315068 | 79 | 0.537156 | false | false | true |
5,715 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CE3906C.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT PUT FOR ENUMERATION TYPES OUTPUTS THE ENUMERATION
-- LITERAL WITH NO TRAILING OR PRECEDING BLANKS WHEN WIDTH IS
-- NOT SPECIFIED OR IS SPECIFIED TO BE LESS THAN OR EQUAL TO THE
-- LENGTH OF THE STRING. CHECK THAT WHEN WIDTH IS SPECIFIED TO
-- BE GREATER THAN THE LENGTH OF THE STRING, TRAILING BLANKS ARE
-- OUTPUT.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- TEXT FILES.
-- HISTORY:
-- SPS 10/08/82
-- SPS 01/03/83
-- VKG 01/07/83
-- JBG 02/22/84 CHANGED TO .ADA TEST.
-- TBN 11/10/86 REVISED TEST TO OUTPUT A NON_APPLICABLE
-- RESULT WHEN FILES ARE NOT SUPPORTED.
-- DWC 09/18/87 REMOVED CALL TO CHECKFILE. CLOSED AND REOPENED
-- FILE AND CHECKED CONTENTS OF FILE USING
-- ENUMERATION_IO GETS.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3906C IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3906C", "CHECK THAT ENUMERATION_IO PUT OUTPUTS " &
"ENUMERATION LITERALS CORRECTLY WITH AND " &
"WITHOUT WIDTH PARAMETERS");
DECLARE
FT : FILE_TYPE;
TYPE MOOD IS (ANGRY, HAPPY, BORED, SAD);
X : MOOD := BORED;
PACKAGE MOOD_IO IS NEW ENUMERATION_IO (MOOD);
CH : CHARACTER;
USE MOOD_IO;
BEGIN
BEGIN
CREATE (FT, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED; TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
END;
DEFAULT_WIDTH := FIELD(IDENT_INT(5));
IF DEFAULT_WIDTH /= FIELD(IDENT_INT(5)) THEN
FAILED ("DEFAULT_WIDTH NOT SET CORRECTLY");
END IF;
PUT (FT, X, 3); -- BORED
X := HAPPY;
NEW_LINE(FT);
PUT (FILE => FT, ITEM => X, WIDTH => 5); -- HAPPY
NEW_LINE (FT);
PUT (FT, SAD, 5); -- SAD
DEFAULT_WIDTH := FIELD(IDENT_INT(6));
PUT (FT, X); -- HAPPY
PUT (FT, SAD, 3); -- SAD
NEW_LINE(FT);
DEFAULT_WIDTH := FIELD(IDENT_INT(2));
PUT (FT, SAD); -- SAD
CLOSE (FT);
BEGIN
OPEN (FT, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT OPEN FOR " &
"IN_FILE MODE");
RAISE INCOMPLETE;
END;
GET (FT, X);
IF X /= BORED THEN
FAILED ("BORED NOT READ CORRECTLY");
END IF;
GET (FT, X);
IF X /= HAPPY THEN
FAILED ("HAPPY NOT READ CORRECTLY - 1");
END IF;
SKIP_LINE (FT);
GET (FT, X);
IF X /= SAD THEN
FAILED ("SAD NOT READ CORRECTLY - 1");
END IF;
GET (FT, CH);
IF CH /= ' ' THEN
FAILED ("BLANKS NOT POSITIONED CORRECTLY - 1");
END IF;
GET (FT, CH);
IF CH /= ' ' THEN
FAILED ("BLANKS NOT POSITIONED CORRECTLY - 2");
END IF;
GET (FT, X);
IF X /= HAPPY THEN
FAILED ("HAPPY NOT READ CORRECTLY - 2");
END IF;
GET (FT, CH);
IF CH /= ' ' THEN
FAILED ("BLANKS NOT POSITIONED CORRECTLY - 3");
END IF;
GET (FT, X);
IF X /= SAD THEN
FAILED ("SAD NOT READ CORRECTLY - 2");
END IF;
SKIP_LINE (FT);
GET (FT, X);
IF X /= SAD THEN
FAILED ("SAD NOT READ CORRECTLY - 3");
END IF;
BEGIN
DELETE (FT);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3906C;
| 32.106742 | 79 | 0.511461 | false | false | true |
2,280 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C95035A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A TASK IS SUSPENDED IF IT REACHES AN ACCEPT STATEMENT
-- PRIOR TO ANY CALL OF THE CORRESPONDING ENTRY.
-- WEI 3/ 4/82
-- JWC 6/28/85 RENAMED FROM C950CAA-B.ADA
with Impdef;
WITH REPORT;
USE REPORT;
PROCEDURE C95035A IS
SUBTYPE ARG IS NATURAL RANGE 0..9;
SPYNUMB : NATURAL := 0;
PROCEDURE PSPY_NUMB (DIGT: IN ARG) IS
BEGIN
SPYNUMB := 10*SPYNUMB+DIGT;
END PSPY_NUMB;
TASK T1 IS
ENTRY E1;
ENTRY BYE;
END T1;
TASK BODY T1 IS
BEGIN
ACCEPT E1;
PSPY_NUMB (2);
ACCEPT BYE;
END T1;
TASK T2;
TASK BODY T2 IS
BEGIN
DELAY 1.0 * Impdef.One_Second;
PSPY_NUMB (1);
T1.E1;
END T2;
BEGIN
TEST ("C95035A", "TASK SUSPENSION PRIOR TO ENTRY CALL");
T1.BYE;
IF SPYNUMB /= 12 THEN
FAILED ("ERROR DURING TASK EXECUTION");
COMMENT ("ACTUAL ORDER WAS:" & INTEGER'IMAGE(SPYNUMB));
END IF;
RESULT;
END C95035A;
| 28.860759 | 79 | 0.628509 | false | false | true |
3,232 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CE3403D.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT SKIP_LINE RAISES CONSTRAINT_ERROR IF SPACING IS
-- ZERO OR NEGATIVE.
-- HISTORY:
-- ABW 08/26/82
-- SPS 09/16/82
-- SPS 11/11/82
-- DWC 09/09/87 ADDED CASE FOR COUNT'LAST.
-- KAS 11/27/95 REMOVED CASES FOR COUNT'LAST
-- TMB 11/19/96 FIXED OBJECTIVE
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3403D IS
FILE : FILE_TYPE;
BEGIN
TEST ("CE3403D" , "CHECK THAT SKIP_LINE RAISES " &
"CONSTRAINT_ERROR IF SPACING IS ZERO, " &
"OR NEGATIVE" );
BEGIN
SKIP_LINE (FILE, POSITIVE_COUNT(IDENT_INT(0)));
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR ZERO");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED FOR ZERO");
END;
BEGIN
SKIP_LINE (FILE, POSITIVE_COUNT(IDENT_INT(-2)));
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR NEGATIVE NUMBER");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED FOR " &
"NEGATIVE NUMBER");
END;
BEGIN
SKIP_LINE (POSITIVE_COUNT(IDENT_INT(0)));
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR ZERO - DEFAULT");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED FOR ZERO " &
"- DEFAULT");
END;
BEGIN
SKIP_LINE (POSITIVE_COUNT(IDENT_INT(-6)));
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR NEGATIVE NUM " &
"- DEFAULT");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED NEGATIVE NUM " &
"- DEFAULT");
END;
RESULT;
END CE3403D;
| 32.32 | 79 | 0.593131 | false | false | true |
5,503 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C57004A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT AN EXIT STATEMENT WITH A LOOP NAME TERMINATES EXECUTION
-- OF THE LOOP STATEMENT WHOSE NAME IT MENTIONS, AND OF ALL OTHER
-- LOOP STATEMENTS (IF ANY) INTERIOR TO THE FIRST LOOP AND ENCLOSING
-- THE EXIT STATEMENT.
-- CASE 1 : UNCONDITIONAL EXITS.
-- RM 04/24/81
-- SPS 3/7/83
WITH REPORT;
PROCEDURE C57004A IS
USE REPORT ;
BEGIN
TEST( "C57004A" , "CHECK THAT A NAMING EXIT STATEMENT TERMINATES" &
" EXECUTION OF THE NAMED LOOP AND OF ALL LOOPS" &
" SITUATED IN-BETWEEN" );
DECLARE
COUNT : INTEGER := 0 ;
BEGIN
OUTERMOST :
FOR X IN INTEGER RANGE 1..2 LOOP
FOR Y IN INTEGER RANGE 1..2 LOOP
COMMENT( "BEFORE 1" );
LOOP1 :
FOR I IN 1..10 LOOP
COMMENT( "INSIDE 1" );
EXIT LOOP1 ;
FAILED( "EXIT NOT OBEYED (1)" );
FOR J IN 1..10 LOOP
FAILED( "OUTER EXIT NOT OBEYED (1)" );
EXIT ;
FAILED( "BOTH EXITS IGNORED (1)" );
END LOOP;
END LOOP LOOP1 ;
COMMENT( "BEFORE 2" );
COUNT := COUNT + 1 ;
LOOP2 :
FOR A IN 1..1 LOOP
FOR B IN 1..1 LOOP
FOR I IN CHARACTER LOOP
COMMENT( "INSIDE 2" );
EXIT LOOP2 ;
FAILED( "EXIT NOT OBEYED (2)" );
FOR J IN BOOLEAN LOOP
FAILED( "OUTER EXIT NOT " &
"OBEYED (2)");
EXIT ;
FAILED( "BOTH EXITS IGNORED " &
"(2)");
END LOOP;
END LOOP;
END LOOP;
END LOOP LOOP2 ;
COMMENT( "BEFORE 3" );
COUNT := COUNT + 1 ;
LOOP3 :
FOR A IN 1..1 LOOP
FOR B IN 1..1 LOOP
FOR I IN BOOLEAN LOOP
COMMENT( "INSIDE 3" );
BEGIN
EXIT LOOP3 ;
FAILED( "EXIT NOT OBEYED (3)" );
END ;
FAILED( "EXIT NOT OBEYED (3BIS)" );
END LOOP;
END LOOP;
END LOOP LOOP3 ;
COMMENT( "BEFORE 4" );
COUNT := COUNT + 1 ;
LOOP4 :
FOR A IN 1..1 LOOP
FOR B IN 1..1 LOOP
FOR I IN INTEGER RANGE 1..10 LOOP
COMMENT( "INSIDE 4" );
CASE A IS
WHEN 1 =>
EXIT LOOP4 ;
FAILED("EXIT NOT OBEYED " &
"(4)" );
END CASE;
FAILED( "EXIT NOT OBEYED (4BIS)" );
END LOOP;
END LOOP;
END LOOP LOOP4 ;
COMMENT( "AFTER 4" );
COUNT := COUNT + 1 ;
EXIT OUTERMOST ;
END LOOP;
FAILED( "MISSED FINAL EXIT" );
END LOOP OUTERMOST ;
IF COUNT /= 4 THEN
FAILED( "WRONG FLOW OF CONTROL" );
END IF;
END ;
RESULT ;
END C57004A ;
| 34.180124 | 79 | 0.394694 | false | false | true |
5,843 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C34007V.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT THE REQUIRED PREDEFINED OPERATIONS ARE DECLARED
-- (IMPLICITLY) FOR DERIVED ACCESS TYPES WHOSE DESIGNATED TYPE IS A
-- ONE-DIMENSIONAL ARRAY TYPE. THIS TEST IS PART 2 OF 2 TESTS
-- WHICH COVER THE OBJECTIVE. THE FIRST PART IS IN TEST C34007D.
-- HISTORY:
-- BCB 04/12/90 CREATED ORIGINAL TEST FROM SPLIT OF C34007D.ADA.
-- THS 09/18/90 REMOVED DECLARATION OF B, DELETED PROCEDURE A,
-- AND REMOVED ALL REFERENCES TO B.
WITH SYSTEM; USE SYSTEM;
WITH REPORT; USE REPORT;
PROCEDURE C34007V IS
SUBTYPE COMPONENT IS INTEGER;
TYPE DESIGNATED IS ARRAY (NATURAL RANGE <>) OF COMPONENT;
SUBTYPE SUBDESIGNATED IS DESIGNATED (IDENT_INT (5) ..
IDENT_INT (7));
PACKAGE PKG IS
TYPE PARENT IS ACCESS DESIGNATED;
FUNCTION CREATE ( F, L : NATURAL;
C : COMPONENT;
DUMMY : PARENT -- TO RESOLVE OVERLOADING.
) RETURN PARENT;
END PKG;
USE PKG;
TYPE T IS NEW PARENT (IDENT_INT (5) .. IDENT_INT (7));
X : T := NEW SUBDESIGNATED'(OTHERS => 2);
K : INTEGER := X'SIZE;
Y : T := NEW SUBDESIGNATED'(1, 2, 3);
W : PARENT := NEW SUBDESIGNATED'(OTHERS => 2);
C : COMPONENT := 1;
N : CONSTANT := 1;
FUNCTION V RETURN T IS
BEGIN
RETURN NEW SUBDESIGNATED'(OTHERS => C);
END V;
PACKAGE BODY PKG IS
FUNCTION CREATE
( F, L : NATURAL;
C : COMPONENT;
DUMMY : PARENT
) RETURN PARENT
IS
A : PARENT := NEW DESIGNATED (F .. L);
B : COMPONENT := C;
BEGIN
FOR I IN F .. L LOOP
A (I) := B;
B := B + 1;
END LOOP;
RETURN A;
END CREATE;
END PKG;
FUNCTION IDENT (X : T) RETURN T IS
BEGIN
IF X = NULL OR ELSE
EQUAL (X'LENGTH, X'LENGTH) THEN
RETURN X; -- ALWAYS EXECUTED.
END IF;
RETURN NEW SUBDESIGNATED;
END IDENT;
BEGIN
TEST ("C34007V", "CHECK THAT THE REQUIRED PREDEFINED OPERATIONS " &
"ARE DECLARED (IMPLICITLY) FOR DERIVED " &
"ACCESS TYPES WHOSE DESIGNATED TYPE IS A " &
"ONE-DIMENSIONAL ARRAY TYPE. THIS TEST IS " &
"PART 2 OF 2 TESTS WHICH COVER THE OBJECTIVE. " &
"THE FIRST PART IS IN TEST C34007V");
W := PARENT (CREATE (2, 3, 4, X));
IF W = NULL OR ELSE W.ALL /= (4, 5) THEN
FAILED ("INCORRECT CONVERSION TO PARENT - 2");
END IF;
X := IDENT (Y);
IF X.ALL /= (1, 2, 3) OR CREATE (2, 3, 4, X) . ALL /= (4, 5) THEN
FAILED ("INCORRECT .ALL (VALUE)");
END IF;
X.ALL := (10, 11, 12);
IF X /= Y OR Y.ALL /= (10, 11, 12) THEN
FAILED ("INCORRECT .ALL (ASSIGNMENT)");
END IF;
Y.ALL := (1, 2, 3);
BEGIN
CREATE (2, 3, 4, X) . ALL := (10, 11);
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION FOR .ALL (ASSIGNMENT)");
END;
X := IDENT (Y);
IF X (IDENT_INT (5)) /= 1 OR
CREATE (2, 3, 4, X) (3) /= 5 THEN
FAILED ("INCORRECT INDEX (VALUE)");
END IF;
Y.ALL := (1, 2, 3);
X := IDENT (Y);
BEGIN
CREATE (2, 3, 4, X) (2) := 10;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION FOR INDEX (ASSIGNMENT)");
END;
IF X (IDENT_INT (6) .. IDENT_INT (7)) /= (2, 3) OR
CREATE (1, 4, 4, X) (1 .. 3) /= (4, 5, 6) THEN
FAILED ("INCORRECT SLICE (VALUE)");
END IF;
Y.ALL := (1, 2, 3);
X := IDENT (Y);
BEGIN
CREATE (1, 4, 4, X) (2 .. 4) := (10, 11, 12);
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION FOR SLICE (ASSIGNMENT)");
END;
IF X = NULL OR X = NEW SUBDESIGNATED OR NOT (X = Y) OR
X = CREATE (2, 3, 4, X) THEN
FAILED ("INCORRECT =");
END IF;
IF X /= Y OR NOT (X /= NULL) OR NOT (X /= CREATE (2, 3, 4, X)) THEN
FAILED ("INCORRECT /=");
END IF;
IF NOT (X IN T) OR CREATE (2, 3, 4, X) IN T THEN
FAILED ("INCORRECT ""IN""");
END IF;
IF X NOT IN T OR NOT (CREATE (2, 3, 4, X) NOT IN T) THEN
FAILED ("INCORRECT ""NOT IN""");
END IF;
RESULT;
END C34007V;
| 31.755435 | 79 | 0.522677 | false | false | true |
489 | ada | Ada | [
"Info-ZIP"
] | 1 | type Data_Array is array(Natural range <>) of Integer;
procedure Insertion_Sort(Item : in out Data_Array) is
First : Natural := Item'First;
Last : Natural := Item'Last;
Value : Integer;
J : Integer;
begin
for I in (First + 1)..Last loop
Value := Item(I);
J := I - 1;
while J in Item'range and then Item(J) > Value loop
Item(J + 1) := Item(J);
J := J - 1;
end loop;
Item(J + 1) := Value;
end loop;
end Insertion_Sort;
| 25.736842 | 57 | 0.568507 | false | false | true |
3,392 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C97201D.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A RENDEZVOUS REQUESTED BY A CONDITIONAL_ENTRY_CALL
-- IS PERFORMED ONLY IF IMMEDIATELY POSSIBLE.
-- CASE D: THE BODY OF THE TASK CONTAINING THE CALLED ENTRY
-- DOES NOT CONTAIN AN ACCEPT_STATEMENT FOR THAT ENTRY -
-- AND THIS FACT IS DETERMINED STATICALLY.
-- RM 4/12/82
WITH REPORT; USE REPORT;
PROCEDURE C97201D IS
ELSE_BRANCH_TAKEN : BOOLEAN := FALSE ;
BEGIN
TEST ("C97201D", "CHECK THAT NO RENDEZVOUS REQUESTED BY" &
" A CONDITIONAL_ENTRY_CALL CAN EVER OCCUR" &
" IN THE ABSENCE OF A CORRESPONDING " &
" ACCEPT_STATEMENT " );
DECLARE
TASK T IS
ENTRY DO_IT_NOW_ORELSE ;
ENTRY KEEP_ALIVE ;
END T ;
TASK BODY T IS
BEGIN
-- NO ACCEPT_STATEMENT FOR THE ENTRY_CALL BEING TESTED
ACCEPT KEEP_ALIVE ; -- TO PREVENT THIS SERVER TASK FROM
-- TERMINATING IF
-- UPON ACTIVATION
-- IT GETS TO RUN
-- AHEAD OF THE CALLER (WHICH
-- WOULD LEAD TO A SUBSEQUENT
-- TASKING_ERROR AT THE TIME OF
-- THE NO-WAIT CALL).
END ;
BEGIN
SELECT
T.DO_IT_NOW_ORELSE ;
ELSE -- (I.E. CALLER ADOPTS A NO-WAIT POLICY)
-- THEREFORE THIS BRANCH MUST BE CHOSEN
ELSE_BRANCH_TAKEN := TRUE ;
COMMENT( "ELSE_BRANCH TAKEN" );
END SELECT;
T.KEEP_ALIVE ; -- THIS ALSO UPDATES THE NONLOCALS
END; -- END OF BLOCK CONTAINING THE ENTRY CALL
-- BY NOW, THE TASK IS TERMINATED
IF ELSE_BRANCH_TAKEN THEN
NULL ;
ELSE
FAILED( "RENDEZVOUS ATTEMPTED?" );
END IF;
RESULT;
END C97201D ;
| 32.932039 | 79 | 0.548644 | false | false | true |
3,365 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CB4008A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT NESTED LAST WISHES EXCEPTION HANDLERS WORK
-- (FOR PROCEDURES).
-- DAT 4/15/81
-- SPS 3/28/83
WITH REPORT; USE REPORT;
PROCEDURE CB4008A IS
C : INTEGER := 0;
E : EXCEPTION;
DEPTH : CONSTANT := 99;
PROCEDURE F;
PROCEDURE I IS
BEGIN
C := C + 1;
IF C >= DEPTH THEN
RAISE E;
END IF;
END I;
PROCEDURE O IS
BEGIN
C := C - 1;
END O;
PROCEDURE X IS
PROCEDURE X1 IS
PROCEDURE X2 IS
BEGIN
F;
END X2;
PROCEDURE X3 IS
BEGIN
I;
X2;
EXCEPTION
WHEN E => O; RAISE;
END X3;
BEGIN
I;
X3;
EXCEPTION
WHEN E => O; RAISE;
END X1;
PROCEDURE X1A IS
BEGIN
I;
X1;
FAILED ("INCORRECT EXECUTION SEQUENCE");
EXCEPTION
WHEN E => O; RAISE;
END X1A;
BEGIN
I;
X1A;
EXCEPTION
WHEN E => O; RAISE;
END X;
PROCEDURE Y IS
BEGIN
I;
X;
EXCEPTION WHEN E => O; RAISE;
END Y;
PROCEDURE F IS
PROCEDURE F2;
PROCEDURE F1 IS
BEGIN
I;
F2;
EXCEPTION WHEN E => O; RAISE;
END F1;
PROCEDURE F2 IS
BEGIN
I;
Y;
EXCEPTION WHEN E => O; RAISE;
END F2;
BEGIN
I;
F1;
EXCEPTION WHEN E => O; RAISE;
END F;
BEGIN
TEST ("CB4008A", "(PROCEDURE) LAST WISHES UNWIND PROPERLY");
BEGIN
I;
Y;
FAILED ("INCORRECT EXECUTION SEQUENCE 2");
EXCEPTION
WHEN E =>
O;
IF C /= 0 THEN
FAILED ("EXCEPTION HANDLER MISSED SOMEWHERE");
END IF;
END;
RESULT;
END CB4008A;
| 24.384058 | 79 | 0.500149 | false | false | true |
4,054 | ada | Ada | [
"BSD-4-Clause",
"BSD-3-Clause"
] | 3 | -- DEMONSTRATION PROGRAM:
-- Features:
-- Enumeration types, ENUM_IO (generic package), records and
-- aggregates, dynamic exception handling, packages, etc.
package DATE_PKGE is
subtype DAY is integer range 1..31;
type MONTH is (Jan, Feb, Mar, Apr, May, Jun,
Jul, Aug, Sep, Oct, Nov, Dec);
subtype YEAR is integer range 0..2000;
type DATE is
record
D : DAY;
M : MONTH;
Y : YEAR;
end record;
function LEAP (Y : YEAR) return Boolean;
function DAYS_IN_MONTH (M : MONTH; IS_LEAP : Boolean)
return DAY;
function VALID (TODAY : DATE) return Boolean;
procedure TOMORROW (TODAY : in out DATE);
procedure READ_DATE (D : out DATE);
procedure WRITE_DATE (D : DATE);
BAD_DATE : exception;
end DATE_PKGE;
with TEXT_IO; use TEXT_IO;
package body DATE_PKGE is
package MONTH_IO is new ENUMERATION_IO (MONTH);
package INT_IO is new INTEGER_IO(integer);
function LEAP (Y : YEAR) return Boolean is
begin
return (Y mod 4 = 0) and not (Y mod 100 = 0);
end LEAP;
function DAYS_IN_MONTH (M : MONTH; IS_LEAP : Boolean)
return DAY is
begin
case M is
when Sep | Apr | Jun | Nov => return 30;
when Feb =>
if IS_LEAP then
return 29;
else
return 28;
end if;
when others => return 31;
end case;
end DAYS_IN_MONTH;
function VALID (TODAY : DATE) return Boolean is
begin
return TODAY.D <= DAYS_IN_MONTH (TODAY.M, LEAP (TODAY.Y));
end VALID;
procedure TOMORROW (TODAY : in out DATE) is
LY : constant Boolean := LEAP (TODAY.Y);
begin
if not VALID (TODAY) then
new_line;
put_line("There can be no tomorrow when there is no today.");
raise BAD_DATE;
elsif TODAY.D < DAYS_IN_MONTH (TODAY.M, LY) then
TODAY.D := TODAY.D + 1; -- not last day of month
elsif TODAY.M < Dec then
TODAY.D := 1; -- last day of month
TODAY.M := MONTH'SUCC (TODAY.M); -- but not last month of year
elsif TODAY.Y < YEAR'LAST then
TODAY := (1, Jan, TODAY.Y + 1); -- last day of year
else
new_line;
put_line(" Beyond the end of time...");
-- run out of years
raise BAD_DATE;
end if;
end TOMORROW;
procedure READ_DATE (D : out DATE) is
use MONTH_IO, INT_IO;
type DATE_COMPONENTS is ('D', 'M', 'Y');
begin
for I in DATE_COMPONENTS
loop
loop
declare
begin
case I is
when 'D' =>
put_line("Day: ");
get (D.D);
when 'M' =>
put_line("Month: ");
get (D.M);
when 'Y' =>
put_line("Year: ");
get (D.Y);
end case;
exit;
exception
when DATA_ERROR | CONSTRAINT_ERROR =>
case I is
when 'D' =>
put_line("Please enter integer from 1 to 31.");
when 'M' =>
put_line(
"Please enter three-letter abbreviation " &
"(i.e. Jan).");
when 'Y' =>
put_line(
"Please enter integer from 0 to 2000.");
end case;
end;
end loop;
end loop;
end READ_DATE;
procedure WRITE_DATE (D : DATE) is
use MONTH_IO, INT_IO;
begin
put (D.M);
put (" ");
put (D.D);
put (", ");
put (D.Y);
end WRITE_DATE;
end DATE_PKGE;
with TEXT_IO, DATE_PKGE; use TEXT_IO, DATE_PKGE;
procedure dates3 is
today : DATE;
begin
loop
declare
begin
READ_DATE (today);
new_line;
put("Today is... ");
WRITE_DATE (today);
TOMORROW (today);
put(" and tomorrow is... ");
WRITE_DATE (today);
new_line(2);
exception
when BAD_DATE =>
new_line;
when END_ERROR =>
new_line;
put_line("Have a nice day!");
exit;
end;
end loop;
end dates3;
| 25.821656 | 72 | 0.537 | false | false | true |
1,463 | ada | Ada | [
"Apache-2.0"
] | 7 | -- CA1012B2.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- WKB 7/20/81
GENERIC
TYPE ELEMENT IS RANGE <>;
FUNCTION CA1012B2 (J : IN ELEMENT) RETURN ELEMENT;
FUNCTION CA1012B2 (J : IN ELEMENT) RETURN ELEMENT IS
BEGIN
RETURN J + 1;
END CA1012B2;
| 38.5 | 79 | 0.677375 | false | false | true |
3,726 | ada | Ada | [
"Apache-2.0"
] | 7 | -- C85009A.ADA
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT PREDEFINED AND USER-DEFINED EXCEPTIONS CAN BE RENAMED
-- AND THAT HANDLERS REFERRING TO EITHER NAME ARE INVOKED WHEN THE
-- EXCEPTION IS RAISED, EVEN BY AN EXPLICIT 'RAISE' STATEMENT
-- REFERRING TO THE OTHER NAME.
-- HISTORY:
-- JET 03/24/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C85009A IS
MY_EXCEPTION : EXCEPTION;
MY_EXCEPTION2 : EXCEPTION RENAMES MY_EXCEPTION;
CONSTRAINT_ERROR2 : EXCEPTION RENAMES CONSTRAINT_ERROR;
I : INTEGER := 1;
BEGIN
TEST ("C85009A", "CHECK THAT PREDEFINED AND USER-DEFINED " &
"EXCEPTIONS CAN BE RENAMED AND THAT HANDLERS " &
"REFERRING TO EITHER NAME ARE INVOKED WHEN " &
"THE EXCEPTION IS RAISED, EVEN BY AN EXPLICIT " &
"'RAISE' STATEMENT REFERRING TO THE OTHER NAME");
BEGIN
RAISE MY_EXCEPTION;
FAILED ("MY_EXCEPTION NOT RAISED");
EXCEPTION
WHEN MY_EXCEPTION2 =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED BY MY_EXCEPTION");
END;
BEGIN
RAISE MY_EXCEPTION2;
FAILED ("MY_EXCEPTION2 NOT RAISED");
EXCEPTION
WHEN MY_EXCEPTION =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED BY MY_EXCEPTION2");
END;
DECLARE
TYPE COLORS IS (RED, BLUE, YELLOW);
E : COLORS := RED;
BEGIN
E := COLORS'PRED(E);
IF NOT EQUAL(COLORS'POS(E),COLORS'POS(E)) THEN
COMMENT("DON'T OPTIMIZE E");
END IF;
FAILED ("CONSTRAINT_ERROR NOT RAISED BY PRED(RED)");
EXCEPTION
WHEN CONSTRAINT_ERROR2 =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED BY PRED(RED)");
END;
BEGIN
RAISE CONSTRAINT_ERROR;
FAILED ("CONSTRAINT_ERROR NOT RAISED");
EXCEPTION
WHEN CONSTRAINT_ERROR2 =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED BY CONSTRAINT_ERROR");
END;
BEGIN
RAISE CONSTRAINT_ERROR2;
FAILED ("CONSTRAINT_ERROR2 NOT RAISED");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED BY CONSTRAINT_ERROR2");
END;
RESULT;
END C85009A;
| 33.872727 | 79 | 0.602791 | false | false | true |
745 | ada | Ada | [
"Info-ZIP"
] | null | with Ada.Text_IO;
with Config; use Config;
procedure Read_Config is
use Ada.Text_IO;
use Rosetta_Config;
begin
New_Line;
Put_Line ("Reading Configuration File.");
Put_Line ("Fullname := " & Get (Key => FULLNAME));
Put_Line ("Favorite Fruit := " & Get (Key => FAVOURITEFRUIT));
Put_Line ("Other Family := " & Get (Key => OTHERFAMILY));
if Has_Value (Key => NEEDSPEELING) then
Put_Line ("NEEDSPEELLING := " & Get (Key => NEEDSPEELING));
else
Put_Line ("NEEDSPEELLING := True");
end if;
if Has_Value (Key => SEEDSREMOVED) then
Put_Line ("SEEDSREMOVED := " & Get (Key => SEEDSREMOVED));
else
Put_Line ("SEEDSREMOVED := True");
end if;
end Read_Config;
| 29.8 | 66 | 0.610738 | false | false | true |
End of preview.
Dataset Description
A subset of the-stack dataset, from 87 programming languages, and 295 extensions.
Each language is in a separate folder under data/
and contains folders of its extensions. We select samples from 20,000 random files of the original dataset, and keep a
maximum of 1,000 files per extension.
Check this space for inspecting this dataset.
Languages
The dataset contains 87 programming languages:
'ada', 'agda', 'alloy', 'antlr', 'applescript', 'assembly', 'augeas', 'awk', 'batchfile', 'bison', 'bluespec', 'c',
'c++', 'c-sharp', 'clojure', 'cmake', 'coffeescript', 'common-lisp', 'css', 'cuda', 'dart', 'dockerfile', 'elixir',
'elm', 'emacs-lisp','erlang', 'f-sharp', 'fortran', 'glsl', 'go', 'groovy', 'haskell','html', 'idris', 'isabelle', 'java',
'java-server-pages', 'javascript', 'julia', 'kotlin', 'lean', 'literate-agda', 'literate-coffeescript', 'literate-haskell',
'lua', 'makefile', 'maple', 'markdown', 'mathematica', 'matlab', 'ocaml', 'pascal', 'perl', 'php', 'powershell', 'prolog',
'protocol-buffer', 'python', 'r', 'racket', 'restructuredtext', 'rmarkdown', 'ruby', 'rust', 'sas', 'scala', 'scheme',
'shell', 'smalltalk', 'solidity', 'sparql', 'sql', 'stan', 'standard-ml', 'stata', 'systemverilog', 'tcl', 'tcsh', 'tex',
'thrift', 'typescript', 'verilog', 'vhdl', 'visual-basic', 'xslt', 'yacc', 'zig'
Dataset Structure
You can specify which language and extension you want to load:
# to load py extension of python
from datasets import load_dataset
load_dataset("bigcode/the-stack-inspection-data", data_dir="data/python/py")
DatasetDict({
train: Dataset({
features: ['content', 'lang', 'size', 'ext', 'max_stars_count', 'avg_line_length', 'max_line_length', 'alphanum_fraction'],
num_rows: 1000
})
})
- Downloads last month
- 61