From 2e784310fb5b2ae888968b1b2dde855080f131bf Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Wed, 7 Apr 2021 23:17:08 +0200 Subject: [PATCH] Add test for blocks --- t/block.t | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 t/block.t diff --git a/t/block.t b/t/block.t new file mode 100644 index 0000000..df6eb5c --- /dev/null +++ b/t/block.t @@ -0,0 +1,42 @@ +(expect "block - return last value" + (equal 'top (block nil 'top))) + +(expect "block - return" + (equal 'ok + (block nil + 'test1 + (return 'ok) + 'fail))) + +(expect "block - return-from" + (equal 'ok + (block banana + 'a + 'b + (return-from banana 'ok) + 'c + 'd))) + +(expect "block - return-from inner block" + (equal 'ok + (block outer + 'a + 'b + (block inner + 'c + (return-from inner 'fail) + 'd) + 'e + 'ok))) + +(expect "block - return-from outer block" + (equal 'ok + (block outer + 'a + 'b + (block inner + 'c + (return-from outer 'ok) + 'd) + 'e + 'fail)))