Hello Guilers, Hope you are all fine and safe.
In the following code, I have a test which should check if my result is correct.
If you change the expected string value "1 run, 1 failed" the assert procedure does not throw.
What happen ? The doc about *with-exception-handler* say things about unwinding, dynamic environment, continuation of the error… Which I barely understand. And here I guess I miss something.
;;;; code under test (define runner (let ([result '(0 0)]) (case-lambda [() (lambda (proc) (run-and-count proc result) result)] [(setup) (lambda (proc) (setup) (run-and-count proc result))] [(setup teardown) (lambda (proc) (setup) (run-and-count proc result) (teardown))]))) (define (run-and-count proc result) (with-exception-handler (lambda (e) (list (1+ (car result)) (1+ (cadr result)))) (lambda () (proc) (list (1+ (car result)) (cadr result))) #:unwind? #t)) (define (summary result) (format #f "~A run, ~A failed" (car result) (cadr result))) ;;;; tests (import (rnrs)) (define (test-failed-result) (let ([test-proc (lambda () (raise-exception (make-exception)))]) (define test-run (runner)) (define result (test-run test-proc)) (assert (string=? "1 run, 1 failed" (summary result))))) (define run (runner)) (run test-failed-result) -- Jérémy Korwin-Zmijowski GPG: 036B 4D54 B7B4 D6C8 DA62 2746 700F 5E0C CBB2 E2D1
OpenPGP_0x700F5E0CCBB2E2D1.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature