I am trying to learn on my own pre and post conditions in ada.
Asked
Active
Viewed 385 times
2
-
Definitely worth mentioning your OS, compiler version, and whether it's FSF or Adacore (if Gnat).Obviously compilers pre-dating Ada-2012 won't support this. – Mar 24 '20 at 11:58
-
I am using jdoodle online compiler is this a problem ? – catrev Mar 24 '20 at 12:03
-
I restored the content of the question. Vandalizing it reduces its value to others. – Mar 24 '20 at 14:04
-
2"the values of A and B are modifified by the pre/post-condition" - this would be an **incredibly bad idea** even if it was spelt right. (a) you should **never** put code that affects the result in the pre/post condition, as you have seen, (b) it makes it very hard indeed to understand what’s going on, life’s hard enough already – Simon Wright Mar 24 '20 at 16:24
-
1Currently the question is "I am trying to learn on my own pre and post conditions in ada." seems like a lot is missing and rather useless. Is this normal ? (ongoing moderation ?) – LoneWanderer Apr 17 '20 at 11:57
1 Answers
5
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);
--...

egilhh
- 6,464
- 1
- 18
- 19