cxa5a10.a
来自「用于进行gcc测试」· A 代码 · 共 552 行 · 第 1/2 页
A
552 行
-- Use the following loops to check for internal consistency between -- inverse functions. declare -- Use the relative error value to account for non-exact -- computations. TC_Relative_Error: Float := 0.005; begin for i in 1..5 loop for j in 0..5 loop if not Incorrect_Inverse_Base_e and not FXA5A00.Result_Within_Range (Float(i)**Float(j), e**(Float(j)*EF.Log(Float(i))), TC_Relative_Error) then Incorrect_Inverse_Base_e := True; Report.Failed("Incorrect Log-** Inverse calc for Base e " & "with i= " & Integer'Image(i) & " and j= " & Integer'Image(j)); end if; if not Incorrect_Inverse_Base_2 and not FXA5A00.Result_Within_Range (Float(i)**Float(j), 2.0**(Float(j)*EF.Log(Float(i),2.0)), TC_Relative_Error) then Incorrect_Inverse_Base_2 := True; Report.Failed("Incorrect Log-** Inverse calc for Base 2 " & "with i= " & Integer'Image(i) & " and j= " & Integer'Image(j)); end if; if not Incorrect_Inverse_Base_8 and not FXA5A00.Result_Within_Range (Float(i)**Float(j), 8.0**(Float(j)*EF.Log(Float(i),8.0)), TC_Relative_Error) then Incorrect_Inverse_Base_8 := True; Report.Failed("Incorrect Log-** Inverse calc for Base 8 " & "with i= " & Integer'Image(i) & " and j= " & Integer'Image(j)); end if; if not Incorrect_Inverse_Base_10 and not FXA5A00.Result_Within_Range (Float(i)**Float(j), 10.0**(Float(j)*EF.Log(Float(i),10.0)), TC_Relative_Error) then Incorrect_Inverse_Base_10 := True; Report.Failed("Incorrect Log-** Inverse calc for Base 10 " & "with i= " & Integer'Image(i) & " and j= " & Integer'Image(j)); end if; if not Incorrect_Inverse_Base_16 and not FXA5A00.Result_Within_Range (Float(i)**Float(j), 16.0**(Float(j)*EF.Log(Float(i),16.0)), TC_Relative_Error) then Incorrect_Inverse_Base_16 := True; Report.Failed("Incorrect Log-** Inverse calc for Base 16 " & "with i= " & Integer'Image(i) & " and j= " & Integer'Image(j)); end if; end loop; end loop; end; -- Reset Flags. Incorrect_Inverse_Base_e := False; Incorrect_Inverse_Base_2 := False; Incorrect_Inverse_Base_8 := False; Incorrect_Inverse_Base_10 := False; Incorrect_Inverse_Base_16 := False; -- Testing of Exp Function, both instantiated and pre-instantiated -- version. -- Check that the result of the Exp Function, when provided an X -- parameter value of 0.0, is 1.0. if GEF.Exp(X => 0.0) /= 1.0 or EF.Exp(0.0) /= 1.0 then Report.Failed("Incorrect result returned by Function Exp when " & "given a parameter value of 0.0"); end if; -- Check that the Exp Function provides correct results when provided -- a variety of input parameter values. if not Result_Within_Range(GEF.Exp(0.001), 1.01, 0.01) or not Result_Within_Range( EF.Exp(0.1), 1.11, 0.01) or not Result_Within_Range(GEF.Exp(1.2697), 3.56, 0.01) or not Result_Within_Range( EF.Exp(3.2525), 25.9, 0.1) or not Result_Within_Range(GEF.Exp(-0.2198), 0.803, 0.001) or not Result_Within_Range( EF.Exp(-1.6621), 0.190, 0.001) or not Result_Within_Range(GEF.Exp(-2.3888), 0.092, 0.001) or not Result_Within_Range( EF.Exp(-5.4415), 0.004, 0.001) then Report.Failed("Incorrect result from Function Exp when provided " & "a variety of input parameter values"); end if; -- Use the following loops to check for internal consistency between -- inverse functions. Arg := 0.01; while Arg < 10.0 loop if not Incorrect_Inverse_Base_e and FXA5A00.Result_Within_Range(EF.Exp(Arg), e**(Arg*EF.Log(Arg)), 0.001) then Incorrect_Inverse_Base_e := True; Report.Failed("Incorrect Exp-** Inverse calc for Base e"); end if; if not Incorrect_Inverse_Base_2 and FXA5A00.Result_Within_Range(EF.Exp(Arg), 2.0**(Arg*EF.Log(Arg,2.0)), 0.001) then Incorrect_Inverse_Base_2 := True; Report.Failed("Incorrect Exp-** Inverse calc for Base 2"); end if; if not Incorrect_Inverse_Base_8 and FXA5A00.Result_Within_Range(EF.Exp(Arg), 8.0**(Arg*EF.Log(Arg,8.0)), 0.001) then Incorrect_Inverse_Base_8 := True; Report.Failed("Incorrect Exp-** Inverse calc for Base 8"); end if; if not Incorrect_Inverse_Base_10 and FXA5A00.Result_Within_Range(EF.Exp(Arg), 10.0**(Arg*EF.Log(Arg,10.0)), 0.001) then Incorrect_Inverse_Base_10 := True; Report.Failed("Incorrect Exp-** Inverse calc for Base 10"); end if; if not Incorrect_Inverse_Base_16 and FXA5A00.Result_Within_Range(EF.Exp(Arg), 16.0**(Arg*EF.Log(Arg,16.0)), 0.001) then Incorrect_Inverse_Base_16 := True; Report.Failed("Incorrect Exp-** Inverse calc for Base 16"); end if; Arg := Arg + 0.01; end loop; -- Testing of Sqrt Function, both instantiated and pre-instantiated -- version. -- Check that Argument_Error is raised by the Sqrt Function when -- the value of the input parameter X is negative. begin Float_Result := EF.Sqrt(X => -FXA5A00.Small); Report.Failed("Argument_Error not raised by Function Sqrt " & "when provided a small negative input parameter " & "value"); Dont_Optimize_Float(Float_Result, 7); exception when Argument_Error => null; -- OK, expected exception. when others => Report.Failed("Unexpected exception raised by Function Sqrt " & "when provided a small negative input parameter " & "value"); end; begin New_Float_Result := GEF.Sqrt(X => -64.0); Report.Failed("Argument_Error not raised by Function Sqrt " & "when provided a large negative input parameter " & "value"); Dont_Optimize_New_Float(New_Float_Result, 8); exception when Argument_Error => null; -- OK, expected exception. when others => Report.Failed("Unexpected exception raised by Function Sqrt " & "when provided a large negative input parameter " & "value"); end; -- Check that the Sqrt Function, when given an X parameter value of 0.0, -- returns a result of 0.0. if GEF.Sqrt(X => 0.0) /= 0.0 or EF.Sqrt(0.0) /= 0.0 then Report.Failed("Incorrect result from Function Sqrt when provided " & "an input parameter value of 0.0"); end if; -- Check that the Sqrt Function, when given an X parameter input value -- of 1.0, returns a result of 1.0. if GEF.Sqrt(X => 1.0) /= 1.0 or EF.Sqrt(1.0) /= 1.0 then Report.Failed("Incorrect result from Function Sqrt when provided " & "an input parameter value of 1.0"); end if; -- Check that the Sqrt Function provides correct results when provided -- a variety of input parameter values. if not FXA5A00.Result_Within_Range(GEF.Sqrt(0.0327), 0.181, 0.001) or not FXA5A00.Result_Within_Range( EF.Sqrt(0.1808), 0.425, 0.001) or not FXA5A00.Result_Within_Range(GEF.Sqrt(1.0556), 1.03, 0.01) or not FXA5A00.Result_Within_Range( EF.Sqrt(32.8208), 5.73, 0.01) or not FXA5A00.Result_Within_Range( EF.Sqrt(27851.0), 166.9, 0.1) or not FXA5A00.Result_Within_Range( EF.Sqrt(61203.4), 247.4, 0.1) or not FXA5A00.Result_Within_Range( EF.Sqrt(655891.0), 809.9, 0.1) then Report.Failed("Incorrect result from Function Sqrt when provided " & "a variety of input parameter values"); end if; -- Check internal consistency between functions. Arg := 0.01; while Arg < 10.0 loop if not Flag_1 and not FXA5A00.Result_Within_Range(Arg, EF.Sqrt(Arg)*EF.Sqrt(Arg), 0.01) then Report.Failed("Inconsistency found in Case 1"); Flag_1 := True; end if; if not Flag_2 and not FXA5A00.Result_Within_Range(Arg, EF.Sqrt(Arg)**2.0, 0.01) then Report.Failed("Inconsistency found in Case 2"); Flag_2 := True; end if; if not Flag_3 and not FXA5A00.Result_Within_Range(EF.Log(Arg), EF.Log(Sqrt(Arg)**2.0), 0.01) then Report.Failed("Inconsistency found in Case 3"); Flag_3 := True; end if; if not Flag_4 and not FXA5A00.Result_Within_Range(EF.Log(Arg), 2.00*EF.Log(EF.Sqrt(Arg)), 0.01) then Report.Failed("Inconsistency found in Case 4"); Flag_4 := True; end if; Arg := Arg + 1.0; end loop; exception when The_Error : others => Report.Failed ("The following exception was raised in the " & "Test_Block: " & Exception_Name(The_Error)); end Test_Block; Report.Result;end CXA5A10;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?