cxb4004.a
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· A 代码 · 共 444 行 · 第 1/2 页
A
444 行
"from an instantiation of Decimal_Conversions " & "using a four-digit Decimal type, with Format " & "parameter Leading_Separate, subtest index: " & Integer'Image(i)); end if; if Package_2.To_Decimal(Package_2_Numeric_Items(i).all, Format => COBOL.Leading_Separate) /= Decimal_Type_2_Items(i) then Report.Failed ("Incorrect result from function To_Decimal " & "from an instantiation of Decimal_Conversions " & "using a ten-digit Decimal type, with Format " & "parameter Leading_Separate, subtest index: " & Integer'Image(i)); end if; when 7..9 => -- Trailing_Separate Display_Format parameter. if Package_1.To_Decimal(Package_1_Numeric_Items(i).all, COBOL.Trailing_Separate) /= Decimal_Type_1_Items(i) then Report.Failed ("Incorrect result from function To_Decimal " & "from an instantiation of Decimal_Conversions " & "using a four-digit Decimal type, with Format " & "parameter Trailing_Separate, subtest index: " & Integer'Image(i)); end if; if Package_2.To_Decimal(Package_2_Numeric_Items(i).all, COBOL.Trailing_Separate) /= Decimal_Type_2_Items(i) then Report.Failed ("Incorrect result from function To_Decimal " & "from an instantiation of Decimal_Conversions " & "using a ten-digit Decimal type, with Format " & "parameter Trailing_Separate, subtest index: " & Integer'Image(i)); end if; end case; end loop; -- Check that function To_Decimal propagates Conversion_Error when -- the value represented by Numeric type parameter Item is outside -- the range of the Decimal_Type Num used to instantiate the package -- Decimal_Conversions. declare TC_Numeric_1 : Decimal_Type_1 := Decimal_Type_1_Items(1); begin -- The COBOL.Numeric type used as parameter Item represents a -- Decimal value that is outside the range of the Decimal type -- used to instantiate Package_1. TC_Numeric_1 := Package_1.To_Decimal(Item => Package_2_Numeric_Items(8).all, Format => COBOL.Trailing_Separate); Report.Failed("Conversion_Error not raised by To_Decimal " & "when the value represented by parameter " & "Item is outside the range of the Decimal_Type " & "used to instantiate the package " & "Decimal_Conversions"); if TC_Numeric_1 = Decimal_Type_1_Items(1) then Report.Comment("To Guard Against Dead Assignment Elimination " & "-- Should never be printed"); end if; exception when COBOL.Conversion_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by To_Decimal " & "when the value represented by parameter " & "Item is outside the range of the Decimal_Type " & "used to instantiate the package " & "Decimal_Conversions"); end; -- Check that function To_Display with decimal type Num and -- Display_Format parameters returns a Numeric type result that -- represents Item under the specific Display_Format. -- Unsigned Display_Format parameter. TC_Num_1 := 13.04; Correct_Result := (Package_1.To_Display(TC_Num_1, COBOL.Unsigned) = "1304") AND (Package_1.To_Display(TC_Num_1, COBOL.Unsigned) /= "13.04"); if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Unsigned Display_Format parameter - 1"); end if; TC_Num_2 := 1234567890.0; Correct_Result := Package_2.To_Display(TC_Num_2, COBOL.Unsigned) = "1234567890"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Unsigned Display_Format parameter - 2"); end if; -- Leading_Separate Display_Format parameter. TC_Num_1 := -34.29; Correct_Result := (Package_1.To_Display(TC_Num_1, COBOL.Leading_Separate) = "-3429") AND (Package_1.To_Display(TC_Num_1, COBOL.Leading_Separate) /= "-34.29"); if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Leading_Separate Display_Format parameter - 1"); end if; TC_Num_1 := 19.01; Correct_Result := Package_1.To_Display(TC_Num_1, COBOL.Leading_Separate) = "+1901"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Leading_Separate Display_Format parameter - 2"); end if; TC_Num_2 := 1234567890.0; Correct_Result := Package_2.To_Display(TC_Num_2, COBOL.Leading_Separate) = "+1234567890"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Leading_Separate Display_Format parameter - 3"); end if; TC_Num_2 := -1234567890.0; Correct_Result := Package_2.To_Display(TC_Num_2, COBOL.Leading_Separate) = "-1234567890"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Leading_Separate Display_Format parameter - 4"); end if; -- Trailing_Separate Display_Format parameter. TC_Num_1 := -99.91; Correct_Result := (Package_1.To_Display(TC_Num_1, COBOL.Trailing_Separate) = "9991-") AND (Package_1.To_Display(TC_Num_1, COBOL.Trailing_Separate) /= "99.91-"); if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Trailing_Separate Display_Format parameter - 1"); end if; TC_Num_1 := 51.99; Correct_Result := Package_1.To_Display(TC_Num_1, COBOL.Trailing_Separate) = "5199+"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Trailing_Separate Display_Format parameter - 2"); end if; TC_Num_2 := 1234567890.0; Correct_Result := Package_2.To_Display(TC_Num_2, COBOL.Trailing_Separate) = "1234567890+"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Trailing_Separate Display_Format parameter - 3"); end if; TC_Num_2 := -1234567890.0; Correct_Result := Package_2.To_Display(TC_Num_2, COBOL.Trailing_Separate) = "1234567890-"; if not Correct_Result then Report.Failed("Incorrect result from function To_Display with " & "Trailing_Separate Display_Format parameter - 4"); end if; -- Check that function To_Display propagates Conversion_Error when -- parameter Item is negative and the specified Display_Format -- parameter is Unsigned. begin if Package_2.To_Display(Item => Decimal_Type_2_Items(9), Format => COBOL.Unsigned) = Package_2_Numeric_Items(2).all then Report.Comment("To Guard Against Dead Assignment Elimination " & "-- Should never be printed"); end if; Report.Failed("Conversion_Error not raised by To_Display " & "when the value represented by parameter " & "Item is negative and the Display_Format " & "parameter is Unsigned"); exception when COBOL.Conversion_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by To_Display " & "when the value represented by parameter " & "Item is negative and the Display_Format " & "parameter is Unsigned"); end; 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 CXB4004;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?