syntax
body-expr)param = param-name:in-type
;sum-n : Nat -> Nat;Given n, return 0 + 1 + 2 + ... + n
syntax
:input-contractin-ctc-expr:output-contractout-ctc-exprbody-expr)
;sum-n : Nat -> Nat;Given n, return 0 + 1 + 2 + ... + n
syntax
( check= actual-exprexpected-expr)
--------------------
FAILURE
name: check=
location: eval:7:0
actual: 10
expected: -32
--------------------
syntax
( defconst *name*expr)
> *num-letters*26
syntax
( test? expr-with-free-vars)
The simplest test? s, without free variables, just check that the expression produces true:
--------------------
FAILURE
name: check-t
location: eval:13:0
params: '(nil)
--------------------
--------------------
FAILURE
name: check-t
location: eval:17:0
params: '(nil)
--------------------
Other test? s might use free variables to test that it works the same way for any values.
To test functions that work on only a certain types of data, you can guard tests with an implies form. The sum-n function works on natural numbers, so you can wrap (implies (natp x)....) around the test expression to test it with only natural numbers.