Search code examples
functionprocedureadapreconditionspost-conditions

ADA - pre and post conditions not working?


I am trying to learn on my own pre and post conditions in ada.


Solution

  • If using GNAT (which looks like it's the default for jdoodle), you need to enable assertions. Add -gnata as a command line parameter.

    EDIT: I don't know much about jdoodle, but it seems it can't take arguments to the compiler, only when running your program...

    Instead, you could add a pragma Assertion_Policy to your program, like this:

    procedure Tp2q4 is
       pragma Assertion_Policy(Check);
    
       --...