From e6cb6bd0472a3e868b7402765c2d83ee2e093c2a Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Thu, 8 Apr 2021 21:49:00 +0200 Subject: [PATCH] Add test for throw and catch --- t/throw_catch.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 t/throw_catch.t diff --git a/t/throw_catch.t b/t/throw_catch.t new file mode 100644 index 0000000..84de627 --- /dev/null +++ b/t/throw_catch.t @@ -0,0 +1,31 @@ +(expect "catch - without throw" + (equal 'ok + (catch 'exc1 + 'ok))) + +(expect "catch - with throw" + (equal 'ok + (catch 'exc2 + (throw 'exc2 'ok) + 'fail))) + +(expect "catch - throw caught by inner catch" + (equal 'ok + (catch 'exc3a + (catch 'exc3b + (throw 'exc3b 'fail)) + 'ok))) + +(expect "catch - throw caught by outer catch" + (equal 'ok + (catch 'exc4a + (catch 'exc4b + (throw 'exc4a 'ok)) + 'fail))) + +(expect "catch - inner catch shadows outer catch" + (equal 'ok + (catch 'exc5 + (catch 'exc5 + (throw 'exc5 'fail)) + 'ok)))