Perfect Developer intermediate tutorial 8 | This page last modified 2011-10-31 (JAC) |
A post-assertion is an assertion given at the end of a method (i.e. after the result or postcondition) that expresses one or more conditions that should be true when the method completes. Each condition should have something to say about the return value (for a function or operator) or the final values of modified objects (for a schema).
For example: in class Money we declared a division-by-integer operator that is supposed to round up the result. If our specification really does round up, we expect that as long we start with a nonzero amount, we end up with a nonzero result. We can express this expectation in a post-assertion like this:
By way of another example: multiplying a Money object by one should give a result equal to the original:
As a final example: calling the adjustPrice schema should not change what versions are available, neither should it affect the price of any version except the one specified. We can verify this by adding post-assertions:
Save My Place | Glossary | Language Reference Manual |
Copyright © 1997-2012 Escher Technologies Limited. All rights reserved. Information is subject to change without notice. |