## parse empty try body
set test try-1
set prog_output "^ans = 2"
do_test try-1.m

## parse empty catch body
set test try-2
set prog_output "^ans = 1"
do_test try-2.m

## supress error; do not execute code after error
set test try-3
set prog_output "^ans = 2"
do_test try-3.m

## execute catch-clause
set test try-4
set prog_output "^ans = 1"
do_test try-4.m

## lasterr works in and out of the catch string.
set test try-5
set prog_output "ans = error: `a' undefined.*\n\nans = error: `a' undefined"
do_test try-5.m

## throw user-defined error
set test try-6
set prog_output "ans = error: user-defined error\n"
do_test try-6.m

## pass lasterr to user-defined subroutine
set test try-7
set prog_output "^ans = <error: `a' undefined.*\n>"
do_test try-7.m

## handle nested try-catch-block: try nested in try
set test try-8
set prog_output "ans = error: `a' undefined.*\n\nans = error: `b' undefined.*\n$"
do_test try-8.m

## handle nested try-catch-block: try nested in catch
set test try-9
set prog_output "ans = error: `b' undefined.*\n\nans = error: `b' undefined.*\n$"
do_test try-9.m

## re-throw an error
set test try-10
set prog_output "ans = error: rethrow: error: `a' undefined.*\n"
do_test try-10.m
