X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tests%2Ftest-agenda.scm;h=9ab65f1cdf57f3ef488ded5d0f33a006f382c4b5;hb=9532a9722a3bf3ba3f4bb9478b3ebd27a3b51af7;hp=691310905b29bbdc7b82b8451e9e62ba2753677f;hpb=a9e932ba04d488a5492afe0dd6d88337f4b01686;p=8sync.git diff --git a/tests/test-agenda.scm b/tests/test-agenda.scm index 6913109..9ab65f1 100644 --- a/tests/test-agenda.scm +++ b/tests/test-agenda.scm @@ -350,23 +350,22 @@ (define* (local-func-gets-break #:key with-indirection) (speaker "Time for exception fun!\n") (let ((caught-exception #f)) - (catch '%8sync-caught-error - (lambda () - (%8sync (%run (if with-indirection - (indirection-remote-func-breaks) - (remote-func-breaks))))) - (lambda (_ orig-key orig-args orig-stacks) - (set! caught-exception #t) - (speaker "in here now!\n") - (test-equal orig-key 'numerical-overflow) - (test-equal orig-args '("/" "Numerical overflow" #f #f)) - (test-assert (list? orig-stacks)) - (test-equal (length orig-stacks) - (if with-indirection 2 1)) - (for-each - (lambda (x) - (test-assert (stack? x))) - orig-stacks))) + (catch-8sync + (%8sync (%run (if with-indirection + (indirection-remote-func-breaks) + (remote-func-breaks)))) + ('numerical-overflow + (lambda (orig-stacks . orig-args) + (set! caught-exception #t) + (speaker "in here now!\n") + (test-equal orig-args '("/" "Numerical overflow" #f #f)) + (test-assert (list? orig-stacks)) + (test-equal (length orig-stacks) + (if with-indirection 2 1)) + (for-each + (lambda (x) + (test-assert (stack? x))) + orig-stacks)))) (test-assert caught-exception)) (speaker "Well that was fun :)\n")) @@ -394,9 +393,34 @@ "in here now!\n" "Well that was fun :)\n"))) +;; Make sure catching tools work + +(let ((speaker (speak-it)) + (catch-result #f)) + (catch-8sync + (begin + (speaker "hello") + (throw '8sync-caught-error + 'my-orig-key '(apple orange banana) '(*fake-stack* *fake-stack* *fake-stack*)) + (speaker "no goodbyes")) + ('some-key + (lambda (stacks . rest) + (speaker "should not happen"))) + ('my-orig-key + (lambda (stacks fruit1 fruit2 fruit3) + (set! catch-result + `((fruit1 ,fruit1) + (fruit2 ,fruit2) + (fruit3 ,fruit3)))))) + (test-equal (speaker) '("hello")) + (test-equal catch-result '((fruit1 apple) + (fruit2 orange) + (fruit3 banana)))) + ;; End tests (test-end "test-agenda") +;; @@: A better way to handle this at the repl? (test-exit)