Can an OCL Post condition be inside an if then statement?
I'm new to OCL and I have some doubts about how the pre and postconditions work.
Can a post condition be placed inside an if then statement?
For example, the following piece of code is valid or I'm just mixing concepts?
Context [some context here] if ( ... some conditions... ) then ( result = 1 post: self.isComplete() -- for example ) endif
Thank you very much for your help
I would rewrite it as:
Context MyContext :: Integer post : if <some condition> then result = 1 endif
If you need more condition you can do this with:
Context MyContext :: Integer post : if <some condition> then -- Another condition if self.isComplete() then result = 1 else result = 0 endif else result = 0 endif
You could use implies operator like below:
context k inv (k.count=0)implies(k.status='nothing')