Skip to content

gnattest: Generates invalid code #43

@jquorning

Description

@jquorning

Consider:

function Say_Hello (Name : String) return String
with
   Post      => Say_Hello'Result in "hello",
   Test_Case => (Name => "Test_Say_Hello",
                 Mode => Nominal);

The 'Result in the postcondition leads to invalid Ada code in read only section:

function Wrap_Test_Say_Hello_7265c2_737355 (Name : String)  return String
is
begin
   declare
      Test_Say_Hello_7265c2_737355_Result : constant String := GNATtest_Generated.GNATtest_Standard.DUT.Say_Hello (Name);
   begin
      begin
         pragma Assert
           (Say_Hello'Result in "hello");
         null;
      exception
         when System.Assertions.Assert_Failure =>
            AUnit.Assertions.Assert
              (False,
               "ens_sloc(dut.ads:0:):Test_Say_Hello test commitment violated");
      end;
      return Test_Say_Hello_7265c2_737355_Result;
   end;
end Wrap_Test_Say_Hello_7265c2_737355;

With:

dut-test_data-tests.adb:40:16: error: attribute "RESULT" can only appear in postcondition of function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions