-- TEST_GENERIC_ELEMENTARY_FUNCTIONS_1.ADA part 1 of multiple part test -- This part tests exceptions and exact values. -- Additional parts test accuracy based on Peter Tang's techniques. -- This is version 0.3, 15-Sep-1991 of a specification compliance test suite -- for the Generic Elementary Functions as specified in -- ISO-IEC/JTC1/SC22/WG9 (Ada) Numerics Rapporteur Group -- Draft 1.2, 12 December 1990 -- The ACVC Ada Compiler Validation Capability philosophy is intended to -- be used. e.g. This is a test against a specification on a specific -- implementation. A specific implementation means the combination of three -- items : 1) a specific Ada compilation system, 2) a specific hardware -- configuration and 3) a specific Generic Elementary Functions -- implementation. The specification is interpreted by the NRG -- the same way ANSI/MIL-STD-1815A is interpreted by the ARG. -- Note to implementors: Once an initial release of this test suite is -- released, there may be periodic updates. There is no guarantee that -- passing any particular version implies passing another version. -- This is the same philosophy as for ACVC. -- When the specification says the domain is unbounded, then the test -- suite checks for no exceptions being raised for FLOAT_TYPE'SAFE_LARGE, -- 'SAFE_SMALL their negatives, and possibly other values. Similarly for a -- domain of X>0 or X>=0 'SAFE_LARGE and 'SAFE_SMALL are used. When there is -- a note about "restricted domain" then the check for no exceptions is made by -- replacing 'SAFE_LARGE reduced by enough to be within the relative -- error. -- The functions are tested in the order the functions appear -- in the specification. Required exceptions are tested first. -- A few tests where exceptions should not occur are tested next. -- Finally, exact values required by the specification are tested. -- This part of the test is itself generic. There are four instantiations -- at the end. Only some instantiations will compile on any given compiler. -- All instantiations that compile must pass the test in order to -- achieve compliance. The instantiations are for FLOAT_TYPE being: -- FLOAT, SHORT_FLOAT, LONG_FLOAT and LONG_LONG_FLOAT. -- The corresponding procedures that must be linked and executed are: -- TEST_ELEMENTART_FUNCTIONS_1 -- TEST_SHORT_ELEMENTARY_FUNCTIONS_1 -- TEST_LONG_ELEMENTARY_FUNCTIONS_1 -- TEST_LONG_LONG_ELEMENTARY_FUNCTIONS_1 -- The compliance test must be compiled from this file, unmodified with -- the following exclusions: If a compiler has not yet implemented -- AI 387, then a global edit may be made to change CONSTRAINT_ERROR -- to CONSTRAINT_ERROR | NUMERIC_ERROR . -- Please report problems or suggested additions to Jon Squire -- Net mail squire@as3.wec.com , phone (301)765-3748 with TEXT_IO; use TEXT_IO; with GENERIC_ELEMENTARY_FUNCTIONS; generic type FLOAT_TYPE is digits <>; procedure TEST_GENERIC_ELEMENTARY_FUNCTIONS_1; procedure TEST_GENERIC_ELEMENTARY_FUNCTIONS_1 is subtype REAL is FLOAT_TYPE; -- run for each hardware type package GEF is new GENERIC_ELEMENTARY_FUNCTIONS(REAL); use GEF; -- package being tested package REAL_IO is new TEXT_IO.FLOAT_IO(REAL); use REAL_IO; -- only used if failure, only in CHECK -- some attributes used below EPSILON : constant REAL := REAL'EPSILON; LARGE : constant REAL := REAL'SAFE_LARGE; M_LARGE : constant REAL := -LARGE; SMALL : constant REAL := REAL'SAFE_SMALL; COT_SMALL : REAL := SMALL; -- must be able to compute 1.0/COT_SMALL -- some values for checking exceptions ONE_PLUS : REAL := 1.0 + EPSILON ; ONE_MINUS : REAL := 1.0 - EPSILON ; PI : constant := 3.14159_26535_89793_23846_26433_83279_50288_41971 ; E : constant := 2.71828_18284_59045_23536_02874_71352_66249_77572 ; HALF_PI : constant := PI / 2.0 ; TWO_PI : constant := 2.0 * PI ; -- variables used in tests Y : REAL; X : REAL := 0.0; ANY_FAIL : BOOLEAN := FALSE; procedure PASSED is begin null; -- this may contain debugging aids during development. end PASSED; procedure FAILED ( MESSAGE : STRING ) is begin ANY_FAIL := TRUE; PUT_LINE("--FAILED " & MESSAGE); end FAILED; begin PUT_LINE("Part 1, test of Generic Elementary Functions"); PUT_LINE("Test for proper exception raising and exact values"); DEFAULT_AFT := REAL'DIGITS + 1; PUT(EPSILON); PUT_LINE(" is EPSILON per FLOAT_TYPE'EPSILON"); PUT(LARGE); PUT_LINE(" is LARGE per FLOAT_TYPE'SAFE_LARGE"); PUT(FLOAT_TYPE'BASE'LAST); PUT_LINE(" is FLOAT_TYPE'BASE'LAST"); PUT(M_LARGE); PUT_LINE(" is M_LARGE per -FLOAT_TYPE'BASE'SAFE_LARGE"); PUT(FLOAT_TYPE'BASE'FIRST); PUT_LINE(" is FLOAT_TYPE'BASE'FIRST"); PUT(SMALL); PUT_LINE(" is FLOAT_TYPE'BASE'SAFE_SMALL"); PUT(FLOAT_TYPE'BASE'SMALL); PUT_LINE(" is FLOAT_TYPE'BASE'SMALL"); -- sanity check on COT_SMALL begin Y := 1.0 / COT_SMALL; exception when others => PUT_LINE(" 1.0/SMALL raises exception"); COT_SMALL := 1.0 / LARGE; -- try again end; begin Y := 1.0 / COT_SMALL; exception when others => PUT_LINE(" COT_SMALL still raises exception, COT tests invalid"); end; -- SQRT -- Declaration: -- function SQRT (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("SQRT testing"); begin -- test for ARGUMENT_ERROR on negative Y := SQRT ( -1.0 ) ; FAILED("ARGUMENT_ERROR not raised SQRT(-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on negative Y := SQRT ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised SQRT(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on negative Y := SQRT ( -SMALL ) ; FAILED("ARGUMENT_ERROR not raised SQRT(-SMALL)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE Y := SQRT ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on SQRT(LARGE)"); end; begin -- test for no exceptions on small Y := SQRT ( SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on SQRT(SMALL)"); end; begin -- test for no exceptions on 0.0 Y := SQRT ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("SQRT(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- LOG (natural base) -- Declaration: -- function LOG (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("LOG (natural base) testing"); begin -- test for ARGUMENT_ERROR on negative Y := LOG ( -1.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(-1.0), should be ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative Y := LOG ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised LOG(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(M_LARGE), should be ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative Y := LOG ( -SMALL ) ; FAILED("ARGUMENT_ERROR not raised LOG(-SMALL)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(-SMALL), should be ARGUMENT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on zero Y := LOG ( 0.0 ) ; FAILED("CONSTRAINT_ERROR not raised LOG(0.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(0.0), should be CONSTRAINT_ERROR"); end; begin -- test for no exceptions on LARGE Y := LOG ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on LOG(LARGE)"); end; begin -- test for no exceptions on small Y := LOG ( SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on LOG(SMALL)"); end; begin -- LOG ( 1.0 ) = 0.0 Y := LOG ( 1.0 ) ; if Y = 0.0 then PASSED; else FAILED("LOG(1.0) = 0.0"); end if; exception when others => FAILED("unexpected exception on LOG(1.0)"); end; -- LOG (arbitrary base) -- Declaration: -- function LOG (X, BASE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("LOG (arbitrary base) testing"); begin -- test for ARGUMENT_ERROR on negative Y := LOG ( -1.0 , 16.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(-1.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative Y := LOG ( M_LARGE , 4.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(M_LARGE,4.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(M_LARGE,4.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative base Y := LOG ( 2.0 , -SMALL ) ; FAILED("ARGUMENT_ERROR not raised LOG(2.0,-SMALL)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(2.0,-SMALL), expected ARGUMENT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on zero Y := LOG ( 0.0 , 2.0 ) ; FAILED("CONSTRAINT_ERROR not raised LOG(0.0,2.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(0.0,2.0), expected CONSTRAINT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero base Y := LOG ( 2.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(2.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(2.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on BASE=1.0 Y := LOG ( 2.0 , 1.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(2.0,1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(2.0,1.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on BASE=1.0 (should never get to 0.0) Y := LOG ( 0.0 , 1.0 ) ; FAILED("ARGUMENT_ERROR not raised LOG(0.0,1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on LOG(0.0,1.0), expected ARGUMENT_ERROR"); end; begin -- test for no exceptions on LARGE Y := LOG ( LARGE , 100.0 ) ; PASSED; exception when others => FAILED("unexpected exception on LOG(LARGE)"); end; begin -- test for no exceptions on small Y := LOG ( SMALL , 2.0 ) ; PASSED; exception when others => FAILED("unexpected exception on LOG(SMALL)"); end; begin -- LOG ( 1.0 , BASE ) = 0.0 Y := LOG ( 1.0 , 2.0 ) ; if Y = 0.0 then PASSED; else FAILED("LOG(1.0,2.0) = 0.0"); end if; Y := LOG ( 1.0 , 0.5 ) ; if Y = 0.0 then PASSED; else FAILED("LOG(1.0,0.5) = 0.0"); end if; exception when others => FAILED("unexpected exception on exact cases"); end; -- EXP -- Declaration: -- function EXP (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("EXP testing"); begin -- test for CONSTRAINT_ERROR on LARGE Y := EXP ( LARGE ) ; FAILED("CONSTRAINT_ERROR not raised EXP(LARGE)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; declare -- test for no exceptions on so_so SO_SO : REAL ; begin SO_SO := LOG(REAL'SAFE_LARGE)*(1.0-8.0*EPSILON); Y := EXP ( SO_SO ) ; PASSED; exception when others => FAILED("unexpected exception on EXP(SO_SO)"); end; begin -- test for no exceptions on M_LARGE Y := EXP ( M_LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on EXP(M_LARGE)"); end; begin -- EXP ( 0.0 ) = 1.0 Y := EXP ( 0.0 ) ; if Y = 1.0 then PASSED; else FAILED("EXP(0.0) = 1.0"); end if; exception when others => FAILED("unexpected exception"); end; -- "**" -- Declaration: -- function "**" (X, Y : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("** testing"); begin -- test for ARGUMENT_ERROR on 0 ** 0 Y := 0.0 ** 0.0 ; FAILED("ARGUMENT_ERROR not raised 0.0 ** 0.0"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception 0.0 ** 0.0, expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative X Y := (-1.0) ** 1.0 ; FAILED("ARGUMENT_ERROR not raised (-1.0) ** 1.0"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception (-1.0) ** 1, expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative X Y := M_LARGE ** 0.0 ; FAILED("ARGUMENT_ERROR not raised M_LARGE ** 0.0 "); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception M_LARGE ** 0, expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative X Y := ( -SMALL ) ** SMALL ; FAILED("ARGUMENT_ERROR not raised (-SMALL) ** SMALL"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception (-small) ** small, expected ARGUMENT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on LARGE Y := LARGE ** LARGE ; FAILED("CONSTRAINT_ERROR not raised LARGE ** LARGE)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception LARGE ** LARGE, expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on 0 ** -1 Y := 0.0 ** (-1.0); FAILED("CONSTRAINT_ERROR not raised 0.0 ** (-1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception 0.0 ** (-1.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on 0 ** (-small) Y := 0.0 ** (-SMALL); FAILED("CONSTRAINT_ERROR not raised 0.0 ** (-SMALL)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception 0.0 ** (-SMALL), expected CONSTRAINT_ERROR"); end; begin --(b) X ** 0.0 = 1.0 Y := 0.001 ** 0.0 ; if Y = 1.0 then PASSED; else FAILED("X ** 0.0 = 1.0"); end if; exception when others => FAILED("unexpected exception on 0.001 ** 0.0"); end; begin --(c) 0.0 ** Y = 0.0 Y := 0.0 ** LARGE ; if Y = 0.0 then PASSED; else FAILED("0.0 ** LARGE = 0.0"); end if; exception when others => FAILED("unexpected exception on 0.0 ** LARGE"); end; begin --(d) X ** 1.0 = X Y := LARGE ** 1.0 ; if Y = LARGE then PASSED; else FAILED("X ** 1.0 = X"); end if; exception when others => FAILED("unexpected exception"); end; begin --(e) 1.0 ** Y = 1.0 Y := 1.0 ** LARGE ; if Y = 1.0 then PASSED; else FAILED("1.0 ** Y = 1.0"); end if; exception when others => FAILED("unexpected exception"); end; -- SIN (natural cycle) -- Declaration: -- function SIN (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("SIN (natural cycle) testing"); begin -- test for no exceptions on LARGE Y := SIN ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on SIN(LARGE)"); end; begin -- test for no exceptions on M_LARGE Y := SIN ( M_LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on SIN(M_LARGE)"); end; begin -- test for exact on 0.0 Y := SIN ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("SIN(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for SIN(X) <= 1.0 Y := SIN ( PI/4.0 ) ; if Y <= 1.0 then PASSED; else FAILED("SIN(PI/4.0) <= 1.0"); end if; exception when others => FAILED("unexpected exception"); end; -- SIN (arbitrary cycle) -- Declaration: -- function SIN (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("SIN (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on negative CYCLE Y := SIN ( 1.0 , -1.0 ) ; FAILED("ARGUMENT_ERROR not raised SIN(1.0,-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero CYCLE Y := SIN ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised SIN(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE Y := SIN ( LARGE , 4.0 ) ; PASSED; exception when others => FAILED("unexpected exception on SIN(LARGE,4.0)"); end; begin -- test for no exceptions on M_LARGE Y := SIN ( M_LARGE , 4.0 ) ; PASSED; exception when others => FAILED("unexpected exception on SIN(M_LARGE,4.0)"); end; begin -- test for exact on 0.0 Y := SIN ( 0.0 , 0.1 ) ; if Y = 0.0 then PASSED; else FAILED("SIN(0.0,0.1) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for exact 0.0 on k*CYCLE/2.0 Y := SIN ( 24.0 , 8.0 ) ; if Y = 0.0 then PASSED; else FAILED("SIN(24.0,8.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- COS (natural cycle) -- Declaration: -- function COS (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COS (natural cycle) testing"); begin -- test for exact on 0.0 Y := COS ( 0.0 ) ; if Y = 1.0 then PASSED; else FAILED("COS(0.0) = 1.0"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE Y := COS ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on COS(LARGE)"); end; begin -- test for no exceptions on M_LARGE Y := COS ( M_LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on COS(M_LARGE)"); end; -- COS (arbitrary cycle) -- Declaration: -- function COS (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COS (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on negative CYCLE Y := COS ( 1.0 , -1.0 ) ; FAILED("ARGUMENT_ERROR not raised COS(1.0,-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero CYCLE Y := COS ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised COS(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for exact on 0.0 Y := COS ( 0.0 , 0.1 ) ; if Y = 1.0 then PASSED; else FAILED("COS(0.0,0.1) = 1.0"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE Y := COS ( LARGE , 4.0 ) ; PASSED; exception when others => FAILED("unexpected exception on COS(LARGE,4.0)"); end; begin -- test for no exceptions on M_LARGE Y := COS ( M_LARGE , 4.0 ) ; PASSED; exception when others => FAILED("unexpected exception on COS(M_LARGE,4.0)"); end; -- TAN (natural cycle) -- Declaration: -- function TAN (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("TAN (natural cycle) testing"); begin -- test for no exceptions on LARGE Y := TAN ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(LARGE)"); end; begin -- test for no exceptions on M_LARGE Y := TAN ( M_LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(M_LARGE)"); end; begin -- test for no exceptions on small Y := TAN ( SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(SMALL)"); end; begin -- test for no exceptions on -small Y := TAN ( -SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(-small)"); end; begin -- test for no exceptions on +/- HALF_PI Y := TAN ( HALF_PI ) ; PASSED; Y := TAN ( -HALF_PI ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(+/- HALF_PI)"); end; begin -- test for +/- PI Y := TAN ( PI ) ; if abs Y < EPSILON then PASSED ; else FAILED("TAN(PI) about zero"); end if ; Y := TAN ( -PI ) ; if abs Y < EPSILON then PASSED ; else FAILED("TAN(-PI) about zero"); end if ; exception when others => FAILED("unexpected exception on TAN(+/- PI)"); end; -- TAN (arbitrary cycle) -- Declaration: -- function TAN (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("TAN (arbitrary cycle) testing"); begin -- test for CONSTRAINT_ERROR on (2k+1)CYCLE/4 Y := TAN ( 5.0 , 4.0 ) ; FAILED("CONSTRAINT_ERROR not raised TAN(5.0,4.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception TAN(5.0,4.0), expected CONSTRAINT_ERROR"); end; begin -- test for ARGUMENT_ERROR on negative CYCLE Y := TAN ( 1.0 , -1.0 ) ; FAILED("ARGUMENT_ERROR not raised TAN(1.0,-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on TAN(1.0,-1.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero CYCLE Y := TAN ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised TAN(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on TAN(1.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for exact on 0.0 Y := TAN ( 0.0 , E ) ; if Y = 0.0 then PASSED; else FAILED("TAN(0.0,e) = 0.0"); end if; exception when others => FAILED("unexpected exception on TAN(0.0,e)"); end; begin -- test for no exceptions on LARGE Y := TAN ( LARGE , E ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(LARGE,E)"); end; begin -- test for no exceptions on M_LARGE Y := TAN ( M_LARGE , E ) ; PASSED; exception when others => FAILED("unexpected exception on TAN(M_LARGE,E)"); end; -- COT (natural cycle) -- Declaration: -- function COT (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COT (natural cycle) testing"); begin -- test for CONSTRAINT_ERROR on 0.0 Y := COT ( 0.0 ) ; FAILED("CONSTRAINT_ERROR not raised COT(0.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(0.0), expected CONSTRAINT_ERROR"); end; begin -- test for no exceptions on LARGE Y := COT ( LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on COT(LARGE)"); end; begin -- test for no exceptions on M_LARGE Y := COT ( M_LARGE ) ; PASSED; exception when others => FAILED("unexpected exception on COT(M_LARGE)"); end; begin -- test for no exceptions on small Y := COT ( COT_SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on COT(COT_SMALL)"); end; begin -- test for no exceptions on -small Y := COT ( -COT_SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on COT(-COT_SMALL)"); end; begin -- test for no exceptions on PI Y := COT ( PI ) ; PASSED; exception when others => FAILED("unexpected exception on COT(PI)"); end; begin -- test for HALF_PI Y := COT ( HALF_PI ) ; if abs Y < EPSILON then PASSED ; else FAILED("COT(HALF_PI) about zero"); end if ; exception when others => FAILED("unexpected exception on COT(HALF_PI)"); end; -- COT (arbitrary cycle) -- Declaration: -- function COT (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COT (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on negative cycle Y := COT ( 1.0 , -1.0 ) ; FAILED("ARGUMENT_ERROR not raised COT(1.0,-1.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(1.0,-1.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := COT ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised COT(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(1.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero cycle (should never get to COT(0.0)) Y := COT ( 0.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised COT(0.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(0.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on zero Y := COT ( 0.0 , 1.0 ) ; FAILED("CONSTRAINT_ERROR not raised COT(0.0,1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(0.0,1.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on k * CYCLE/2 Y := COT ( 1.0 , 2.0 ) ; FAILED("CONSTRAINT_ERROR not raised COT(1.0,2.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(1.0,2.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on k * CYCLE/2 Y := COT ( 4.0 , 2.0 ) ; FAILED("CONSTRAINT_ERROR not raised COT(4.0,2.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(4.0,2.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on k * CYCLE/2 Y := COT ( 4096.0 , 2.0 ) ; FAILED("CONSTRAINT_ERROR not raised COT(4096.0,2.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COT(4096.0,2.0), expected CONSTRAINT_ERROR"); end; begin -- test for no exceptions on LARGE Y := COT ( LARGE , E ) ; PASSED; exception when others => FAILED("unexpected exception on COT(LARGE,E)"); end; begin -- test for no exceptions on M_LARGE Y := COT ( M_LARGE , E ) ; PASSED; exception when others => FAILED("unexpected exception on COT(M_LARGE,E)"); end; -- ARCSIN (natural cycle) -- Declaration: -- function ARCSIN (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCSIN (natural cycle) testing"); begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( ONE_PLUS ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(1.0+EPSILON)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( -ONE_PLUS ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(-1.0-EPSILON)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for exact on 0.0 Y := ARCSIN ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCSIN(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- ARCSIN (arbitrary cycle) -- Declaration: -- function ARCSIN (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCSIN (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( 1.0 + EPSILON , E ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(1.0+EPSILON,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( -(1.0+EPSILON) , E ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(-1.0-EPSILON,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( M_LARGE , E ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(M_LARGE,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCSIN ( LARGE , E ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(LARGE,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCSIN ( 2.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(2.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCSIN(2.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCSIN ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCSIN(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCSIN(1.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for exact on 0.0 Y := ARCSIN ( 0.0 , E ) ; if Y = 0.0 then PASSED; else FAILED("ARCSIN(0.0,E) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- ARCCOS (natural cycle) -- Declaration: -- function ARCCOS (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCCOS (natural cycle) testing"); begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( 1.0 + EPSILON ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(1.0+EPSILON)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( -(1.0+EPSILON) ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(-1.0-EPSILON)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for exact on 1.0 Y := ARCCOS ( 1.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCCOS(1.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- ARCCOS (arbitrary cycle) -- Declaration: -- function ARCCOS (X, CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCCOS (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( 1.0 + EPSILON , E ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(1.0+EPSILON,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( -(1.0+EPSILON) , E ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(-1.0-EPSILON,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( M_LARGE , E ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(M_LARGE,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCCOS ( LARGE , E ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(LARGE,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCCOS ( 1.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(1.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOS(1.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCCOS ( 2.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOS(2.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOS(2.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for exact on 1.0 Y := ARCCOS ( 1.0 , E ) ; if Y = 0.0 then PASSED; else FAILED("ARCCOS(1.0,E) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for exact on 0.0 Y := ARCCOS ( 0.0 , 1.0 ) ; if Y = 0.25 then PASSED; else FAILED("ARCCOS(0.0,1.0) = 0.25"); end if; exception when others => FAILED("unexpected exception"); end; begin -- test for exact on -1.0 Y := ARCCOS ( -1.0 , 1.0 ) ; if Y = 0.5 then PASSED; else FAILED("ARCCOS(-1.0,1.0) = 0.5"); end if; exception when others => FAILED("unexpected exception"); end; -- CHECK( ARCCOS ( -1.0 , 2.0 ) , 1.0 , 1.0 ) ; -- CHECK( ARCCOS ( 0.0 , 2.0 ) , 0.5 , 1.0 ) ; -- ARCTAN (natural cycle) -- Declaration: -- function ARCTAN (Y : FLOAT_TYPE; -- X : FLOAT_TYPE := 1.0) return FLOAT_TYPE; PUT_LINE("ARCTAN (natural cycle) testing"); begin -- test for ARGUMENT_ERROR on 0.0,0.0 Y := ARCTAN ( 0.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCTAN(0.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE, M_LARGE and small Y := ARCTAN ( LARGE ) ; Y := ARCTAN ( M_LARGE ) ; Y := ARCTAN ( SMALL ) ; Y := ARCTAN ( -SMALL ) ; PASSED; exception when others => FAILED("unexpected exception on ARCTAN(LARGE,M_LARGE,SMALL combinations)"); end; begin -- test for exact on 0.0 Y := ARCTAN ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCTAN(0.0)=0.0"); end if; exception when others => FAILED("unexpected exception on ARCTAN(0.0)"); end; begin -- test for exact on 0.0,X Y := ARCTAN ( 0.0 , E ) ; if Y = 0.0 then PASSED; else FAILED("ARCTAN(0.0,e)=0.0"); end if; exception when others => FAILED("unexpected exception on ARCTAN(0.0,e)"); end; begin -- test for almost exact on 0.0,-X Y,0.0 -Y,0.0 Y := ARCTAN ( 0.0 , -E ) ; Y := ARCTAN ( E , 0.0 ) ; Y := ARCTAN ( -E , 0.0 ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCTAN(0.0,E) and others"); end; -- ARCTAN (arbitrary cycle) -- Declaration: -- function ARCTAN (Y : FLOAT_TYPE; -- X : FLOAT_TYPE := 1.0; -- CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCTAN (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on 0.0,0.0 Y := ARCTAN ( 0.0 , 0.0 , E ) ; FAILED("ARGUMENT_ERROR not raised ARCTAN(0.0,0.0,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCTAN ( 2.0 , 0.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCTAN(2.0,0.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTAN(2.0,0.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for no exceptions on LARGE, M_LARGE and small Y := ARCTAN ( LARGE , LARGE , 360.0 ) ; Y := ARCTAN ( LARGE , SMALL , E ) ; Y := ARCTAN ( LARGE , M_LARGE , E ) ; Y := ARCTAN ( M_LARGE , M_LARGE , 360.0 ) ; Y := ARCTAN ( M_LARGE , LARGE , E ) ; Y := ARCTAN ( M_LARGE , SMALL , E ) ; Y := ARCTAN ( SMALL , SMALL , 360.0 ) ; Y := ARCTAN ( SMALL , LARGE , E ) ; Y := ARCTAN ( SMALL , M_LARGE , E ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCTAN(LARGE,M_LARGE,SMALL combinations)"); end; begin -- test for exact on 0.0,X Y := ARCTAN ( 0.0 , E , 360.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCTAN(0.0,e,360.0)=0.0"); end if; exception when others => FAILED("unexpected exception on ARCTAN(0.0,e)"); end; begin -- test for almost exact on 0.0,-X Y,0.0 -Y,0.0 Y := ARCTAN ( 0.0 , -E , 360.0 ) ; Y := ARCTAN ( E , 0.0 , 360.0 ) ; Y := ARCTAN ( -E , 0.0 , 360.0 ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCTAN(0.0,E,CYCLE) and others"); end; -- ARCCOT (natural cycle) -- Declaration: -- function ARCCOT (X : FLOAT_TYPE; -- Y : FLOAT_TYPE := 1.0) return FLOAT_TYPE; PUT_LINE("ARCCOT (natural cycle) testing"); begin -- test for ARGUMENT_ERROR on 0.0,0.0 Y := ARCCOT ( 0.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOT(0.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for no exceptions on LARGE, M_LARGE and small Y := ARCCOT ( LARGE ) ; if Y >= 0.0 and Y < 4.0 * EPSILON then PASSED; else FAILED("ARCCOT(LARGE)"); end if; Y := ARCCOT ( M_LARGE ) ; Y := ARCCOT ( SMALL ) ; Y := ARCCOT ( -SMALL ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCCOT(LARGE,M_LARGE,SMALL combinations)"); end; begin -- test for exact on 0.0 Y := ARCCOT ( 0.0 ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCCOT(0.0)"); end; begin -- test for almost exact on 0.0,Y 0.0,-Y X,0.0 -X,0.0 Y := ARCCOT ( 0.0 , E ) ; Y := ARCCOT ( 0.0 , -E ) ; Y := ARCCOT ( E , 0.0 ) ; Y := ARCCOT ( -E , 0.0 ) ; PASSED; exception when others => FAILED("unexpected exception on ARCCOT(0.0,E) and others"); end; -- ARCCOT (arbitrary cycle) -- Declaration: -- function ARCCOT (X : FLOAT_TYPE; -- Y : FLOAT_TYPE := 1.0; -- CYCLE : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCCOT (arbitrary cycle) testing"); begin -- test for ARGUMENT_ERROR on 0.0,0.0 Y := ARCCOT ( 0.0 , 0.0 , E ) ; FAILED("ARGUMENT_ERROR not raised ARCCOT(0.0,0.0,E)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on zero cycle Y := ARCCOT ( 2.0 , 0.0 , 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOT(2.0,0.0,0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOT(2.0,0.0,0.0), expected ARGUMENT_ERROR"); end; begin -- test for no exceptions on LARGE, M_LARGE and small Y := ARCCOT ( LARGE , 1.0 , E ) ; if Y >= 0.0 and Y < 4.0 * EPSILON then PASSED; else FAILED("ARCCOT(LARGE,1,E)"); end if; Y := ARCCOT ( M_LARGE , 1.0 , 360.0 ) ; Y := ARCCOT ( SMALL , 1.0 , 360.0 ) ; Y := ARCCOT ( -SMALL , 1.0 , 360.0 ) ; PASSED ; exception when others => FAILED("unexpected exception on ARCCOT(LARGE,M_LARGE,SMALL combinations)"); end; begin -- test for almost exact on 0.0,Y 0.0,-Y X,0.0 -X,0.0 Y := ARCCOT ( 0.0 , E , TWO_PI ) ; Y := ARCCOT ( 0.0 , -E , 360.0 ) ; Y := ARCCOT ( E , 0.0 , E ) ; Y := ARCCOT ( -E , 0.0 , 360.0 ) ; PASSED; exception when others => FAILED("unexpected exception on ARCCOT(0.0,E) and others"); end; -- SINH -- Declaration: -- function SINH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("SINH testing"); begin -- SINH ( 0.0 ) = 0.0 Y := SINH ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("SINH(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- COSH -- Declaration: -- function COSH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COSH testing"); begin -- COSH ( 0.0 ) = 1.0 Y := COSH ( 0.0 ) ; if Y = 1.0 then PASSED; else FAILED("COSH(0.0) = 1.0"); end if; exception when others => FAILED("unexpected exception"); end; -- TANH -- Declaration: -- function TANH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("TANH testing"); begin -- TANH ( 0.0 ) = 0.0 Y := TANH ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("TANH(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- COTH -- Declaration: -- function COTH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("COTH testing"); begin -- test for CONSTRAINT_ERROR on COTH(0.0) Y := COTH ( 0.0 ) ; FAILED("CONSTRAINT_ERROR not raised COTH(0.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on COTH(0.0), expected CONSTRAINT_ERROR"); end; -- ARCSINH -- Declaration: -- function ARCSINH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCSINH testing"); begin -- ARCSINH ( 0.0 ) = 0.0 Y := ARCSINH ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCSINH(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- ARCCOSH -- Declaration: -- function ARCCOSH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCCOSH testing"); begin -- test for ARGUMENT_ERROR on X<1.0 Y := ARCCOSH ( 1.0-EPSILON ) ; FAILED("ARGUMENT_ERROR not raised ARCCOSH(1.0-EPSILON)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on X<1.0 Y := ARCCOSH ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCCOSH(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- test for ARGUMENT_ERROR on X<1.0 Y := ARCCOSH ( 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOSH(0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception"); end; begin -- ARCCOSH ( 1.0 ) = 0.0 Y := ARCCOSH ( 1.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCCOSH(1.0) = 0.0"); end if; exception when others => FAILED("unexpected exception"); end; -- ARCTANH -- Declaration: -- function ARCTANH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCTANH testing"); begin -- test for CONSTRAINT_ERROR on |X|=1.0 Y := ARCTANH ( 1.0 ) ; FAILED("CONSTRAINT_ERROR not raised ARCTANH(1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(1.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on |X|=1.0 Y := ARCTANH ( -1.0 ) ; FAILED("CONSTRAINT_ERROR not raised ARCTANH(-1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(-1.0), expected CONSTRAINT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCTANH ( ONE_PLUS ) ; FAILED("ARGUMENT_ERROR not raised ARCTANH(1.0+epsilon)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(1.0+epsilon), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|>1.0 Y := ARCTANH ( -ONE_PLUS ) ; FAILED("ARGUMENT_ERROR not raised ARCTANH(-1.0-epsilon)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(-1.0-epsilon), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|>=1.0 Y := ARCTANH ( M_LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCTANH(M_LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(M_LARGE), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|>=1.0 Y := ARCTANH ( LARGE ) ; FAILED("ARGUMENT_ERROR not raised ARCTANH(LARGE)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCTANH(LARGE), expected ARGUMENT_ERROR"); end; begin -- ARCTANH ( 0.0 ) = 0.0 Y := ARCTANH ( 0.0 ) ; if Y = 0.0 then PASSED; else FAILED("ARCTANH(0.0) = 0.0"); end if; exception when others => FAILED("unexpected exception on ARCTANH(0.0)"); end; -- ARCCOTH -- Declaration: -- function ARCCOTH (X : FLOAT_TYPE) return FLOAT_TYPE; PUT_LINE("ARCCOTH testing"); begin -- test for CONSTRAINT_ERROR on |X|=1.0 Y := ARCCOTH ( 1.0 ) ; FAILED("CONSTRAINT_ERROR not raised ARCCOTH(1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(1.0), expected CONSTRAINT_ERROR"); end; begin -- test for CONSTRAINT_ERROR on |X|=1.0 Y := ARCCOTH ( -1.0 ) ; FAILED("CONSTRAINT_ERROR not raised ARCCOTH(-1.0)"); exception when CONSTRAINT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(-1.0), expected CONSTRAINT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|<1.0 Y := ARCCOTH ( ONE_MINUS ) ; FAILED("ARGUMENT_ERROR not raised ARCCOTH(1.0-epsilon)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(1.0-epsilon), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|<1.0 Y := ARCCOTH ( -ONE_MINUS ) ; FAILED("ARGUMENT_ERROR not raised ARCCOTH(-1.0+epsilon)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(-1.0+epsilon), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|<=1.0 Y := ARCCOTH ( 0.0 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOTH(0.0)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(0.0), expected ARGUMENT_ERROR"); end; begin -- test for ARGUMENT_ERROR on |X|<=1.0 Y := ARCCOTH ( 0.5 ) ; FAILED("ARGUMENT_ERROR not raised ARCCOTH(0.5)"); exception when ARGUMENT_ERROR => PASSED; when others => FAILED("unexpected exception on ARCCOTH(0.5), expected ARGUMENT_ERROR"); end; NEW_LINE; PUT("Generic Elementary Functions specification compliance test "); if ANY_FAIL then PUT_LINE("FAILED"); else PUT_LINE("PASSED"); end if; NEW_LINE; end TEST_GENERIC_ELEMENTARY_FUNCTIONS_1 ; -- Even if some of these compilation units fail, others will compile. -- The compliance test must be run on all that compile. with TEST_GENERIC_ELEMENTARY_FUNCTIONS_1; procedure TEST_ELEMENTARY_FUNCTIONS_1 is new TEST_GENERIC_ELEMENTARY_FUNCTIONS_1 ( FLOAT ) ; with TEST_GENERIC_ELEMENTARY_FUNCTIONS_1; procedure TEST_LONG_ELEMENTARY_FUNCTIONS_1 is new TEST_GENERIC_ELEMENTARY_FUNCTIONS_1 ( LONG_FLOAT ) ;