Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnalyzer ¶
Types ¶
type Contract ¶
type Contract struct { Pos token.Pos // contract position, used for positioning debug messages Condition string // valid Go-syntax expression which if true, the contract is violated Names []string // unbound variables used by the condition Message string // error message to show on contract failure }
type Function ¶
func (Function) MapArgs ¶
MapArgs converts list of expressions to strings and maps them to function argument names.
func (Function) Validate ¶
Validate chackes all contracts for a function using the given function arguments.
If a contract is violated, that contract is returned.
Possible return values:
- (contract, nil): a contract is violated, that contract is returned.
- (nil, SomeError): one or more contracts failed, the first failure is returned.
If a contract failed and another one succeeded but violated, the error is nil and the violated contract is returned. In other words, don't worry that we cannot execute a contract if we have a meaningful error to show for another contract. That allows the analyzer to safely ignore contract errors.
Click to show internal directories.
Click to hide internal directories.