diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-21 13:25:53 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-21 13:25:53 +0200 |
commit | 692a7c4c7ffba171ebb66a31b674e9f117df1fe2 (patch) | |
tree | 29a0b2ba1a58d8a185f10ebc972f1848e5dbb89b /tests/02_runtime | |
parent | 322fb503de8c38b0ee3ba1625e2d9197a4f8cba4 (diff) |
tests: add try/catch testcase
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/02_runtime')
-rw-r--r-- | tests/02_runtime/03_try_catch | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/02_runtime/03_try_catch b/tests/02_runtime/03_try_catch new file mode 100644 index 0000000..518c1f1 --- /dev/null +++ b/tests/02_runtime/03_try_catch @@ -0,0 +1,31 @@ +Wrapping an exeptional operation in try {} catch {} allows handling the +resulting exception and to continue the execution flow. + +-- Expect stdout -- +Catched first exception. +Catched second exception: exception 2. +After exceptions. +-- End -- + +-- Testcase -- +{% + // A try-catch block that discards the exception information. + try { + die("exception 1"); + } + catch { + print("Catched first exception.\n"); + } + + // A try-catch block that captures the resulting exception in + // the given variable. + try { + die("exception 2"); + } + catch (e) { + print("Catched second exception: ", e, ".\n"); + } + + print("After exceptions.\n"); +%} +-- End -- |