;'<<SPEC'
### `catch` ###
FIXME: We don't really need all of List for these tests, just `list`
and `literal`.
-> Tests for functionality "Evaluate Robin Expression (with List)"
`catch` installs an exception handler.
If an exception is raised when evaluating the final argument of
`catch`, the exception value is bound to the symbol given as the
first argument of `catch`, and the second argument of `catch` is
evaluated in that new environment.
| (catch error (list error #f)
| (raise (literal (nasty-value 999999))))
= ((nasty-value 999999) #f)
If an exception is raised in the body of a macro that is applied
in the context of a `catch`, it will still be catched.
| (bind errorful (macro (self args env) (raise (literal (nasty-value 1111))))
| (catch error (list error #f)
| (errorful joe)))
= ((nasty-value 1111) #f)
If nothing is raised, `catch` will evaluate to whatever its body
evaluated to.
| (catch error (list error #f) 42)
= 42
The innermost `catch` will catch the exception.
| (catch error (list error 5)
| (catch error (list error 9)
| (raise (literal derpy-value))))
= (derpy-value 9)
An exception raised from within an exception handler is
caught by the next innermost exception handler.
| (catch error (list error 5)
| (catch error (list error 9)
| (catch error (raise (list error error))
| (raise 7))))
= ((7 7) 9)
`catch` expects its first argument to be a symbol.
| (catch (3 4) (list error #f) 42)
? uncaught exception: (illegal-arguments ((3 4) (list error #f) 42))
`catch` expects exactly three arguments.
| (catch error (list error #f))
? uncaught exception: (illegal-arguments (error (list error #f)))
| (catch error (list error #f) 42 43)
? uncaught exception: (illegal-arguments (error (list error #f) 42 43))
'<<SPEC'
(require catch)