aboutsummaryrefslogtreecommitdiffstats
path: root/tests/values.scm
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-12-31 00:13:58 -0500
committerGravatar Peter McGoron 2024-12-31 00:13:58 -0500
commitec5cef664e74a01f1851890b1eeec44e9c88ee6a (patch)
treef1f4225d123128071fca653c95f7b534e570c3c0 /tests/values.scm
parentfix define-record-type/destructor and refactor tests (diff)
add on-error!
Diffstat (limited to 'tests/values.scm')
-rw-r--r--tests/values.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/values.scm b/tests/values.scm
index f1d63f7..cafa8b0 100644
--- a/tests/values.scm
+++ b/tests/values.scm
@@ -108,6 +108,34 @@
(test-assert "length-at-least=> 3.4" (equal? rest '(4))))
(else (error "length-at-least=> 3" #f)))
+(test "on-fail 1"
+ 5
+ (cond-thunk
+ (after ((when #t)
+ (on-fail! 5)
+ (when #f))
+ 'no-fail)
+ (else 'else)))
+
+(test "on-fail 2"
+ 'caught
+ (guard (x ((eq? x 'throw) 'caught) (else 'something-else))
+ (cond-thunk
+ (after ((when #t)
+ (on-fail! (raise 'throw))
+ (when #f))
+ 'no-failed)
+ (else 'else))))
+
+(test "on-fail 3"
+ 'no-fail
+ (cond-thunk
+ (after ((on-fail! 'fail1)
+ (when #t)
+ (on-fail! 'fail2))
+ 'no-fail)
+ (else 'else)))
+
(define-syntax with-catch-predicate
(syntax-rules ()
((with-catch-predicate predicate? body ...)