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.

conditionthe boolean expression to check

Since: Phase C1

defmacro

assert-msg!

(assert-msg! [condition msg])

unconditional sanity check with custom panic message.

conditionthe boolean expression to check
msgthe message string to use when panicking

Since: Phase C1

defmacro

require!

(require! [condition])

precondition check at function entry, panics with "Precondition failed" if false.

conditionthe boolean precondition to enforce

Since: Phase C1

defmacro

require-msg!

(require-msg! [condition msg])

precondition check with custom panic message.

conditionthe boolean precondition to enforce
msgthe message string to use when panicking

Since: Phase C1

defmacro

ensure!

(ensure! [condition])

postcondition check, panics with "Postcondition failed" if false.

conditionthe boolean postcondition to enforce

Since: Phase C1

defmacro

ensure-msg!

(ensure-msg! [condition msg])

postcondition check with custom panic message.

conditionthe boolean postcondition to enforce
msgthe 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.

objthe value to check
predicatea 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.

objthe value to check
predicatea single-argument function that returns true if the invariant holds
msgthe 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.