diff options
| author | 2024-12-28 23:00:53 -0500 | |
|---|---|---|
| committer | 2024-12-28 23:00:53 -0500 | |
| commit | a7d440f5b5e1d048fb51174c2d719bb460ff936d (patch) | |
| tree | ca3cab0d63e3cf4dffbbc6e984b727ae111bed4e | |
| parent | refactor string exceptions (diff) | |
refactor tests to check type of exception
| -rw-r--r-- | tests/run.scm | 13 | ||||
| -rw-r--r-- | tests/string.scm | 7 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tests/run.scm b/tests/run.scm index f62c232..b3fa91c 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -19,7 +19,18 @@ ;;; TODO: Make a custom SRFI-64 test runner that emulates CHICKEN test. -(import (mcgoron iterator base)) +(import (mcgoron iterator base) + (mcgoron iterator exceptions)) + +(define-syntax with-exception-check + (syntax-rules () + ((_ type body ...) + (guard (ex + ((not (iterator-exception? ex)) (raise ex)) + ((eq? (iterator-exception-type ex) (quote type)) + #t) + (else #f)) + body ...)))) (include "string.scm") #;(include "list.scm") diff --git a/tests/string.scm b/tests/string.scm index 7625acc..e8d2671 100644 --- a/tests/string.scm +++ b/tests/string.scm @@ -26,7 +26,8 @@ (iterator-advance itr 0))) (test "iterator->index" 0 (iterator->index itr)) (test-assert "iterator=?" (iterator=? itr (string-iterator-end str))) - (test-error "iterator-ref" (iterator-ref itr)))) + (test-assert "iterator-ref" (with-exception-check ref-at-end + (iterator-ref itr))))) (let* ((str "a") (itr (string-iterator-start str)) @@ -50,5 +51,7 @@ (iterator=? itr (iterator-advance next-itr -1))) (test "iterator->index next-itr" 1 (iterator->index next-itr)) - (test-error "iterator-ref next-itr" (iterator-ref next-itr))))) + (test-assert "iterator-ref next-itr" + (with-exception-check ref-at-end + (iterator-ref next-itr)))))) |
