tur/contract
stdlib/contract.tur
defn
contract-enabled?
(contract-enabled? :bool)
returns true when contracts are enabled at runtime.
Since: Phase C1
defmacro
assert!
(assert! [condition])
unconditional sanity check, panics with "Assertion failed" if false.
Parameters
| condition | the boolean expression to check |
Since: Phase C1
defmacro
assert-msg!
(assert-msg! [condition msg])
unconditional sanity check with custom panic message.
Parameters
| condition | the boolean expression to check | |
| msg | the message string to use when panicking |
Since: Phase C1
defmacro
require!
(require! [condition])
precondition check at function entry, panics with "Precondition failed" if false.
Parameters
| condition | the boolean precondition to enforce |
Since: Phase C1
defmacro
require-msg!
(require-msg! [condition msg])
precondition check with custom panic message.
Parameters
| condition | the boolean precondition to enforce | |
| msg | the message string to use when panicking |
Since: Phase C1
defmacro
ensure!
(ensure! [condition])
postcondition check, panics with "Postcondition failed" if false.
Parameters
| condition | the boolean postcondition to enforce |
Since: Phase C1
defmacro
ensure-msg!
(ensure-msg! [condition msg])
postcondition check with custom panic message.
Parameters
| condition | the boolean postcondition to enforce | |
| msg | the message string to use when panicking |
Since: Phase C1
defmacro
invariant!
(invariant! [obj predicate])
check a structural invariant on a value, panics with "Invariant failed" if false.
Parameters
| obj | the value to check | |
| predicate | a single-argument function that returns true if the invariant holds |
Since: Phase C1
defmacro
invariant-msg!
(invariant-msg! [obj predicate msg])
check a structural invariant with custom panic message.
Parameters
| obj | the value to check | |
| predicate | a single-argument function that returns true if the invariant holds | |
| msg | the message string to use when panicking |
Since: Phase C1
Internal definitions
tur-contract-check-- internal helper called by contract macros.tur-contract-check-inv-- internal helper for invariant macros.