Debian Codegraph @

scheme/tests/guardians.ss

raw
1
2 (library (tests guardians)
3 (export run-tests)
4 (import (ikarus))
5
6 (define (test1)
7 (define (for-each-pair f x)
8 (when (pair? x)
9 (f x)
10 (for-each-pair f (cdr x))))
11
12 (define n 100)
13
14 (define ls (make-list n))
15
16 (define g (make-guardian))
17
18 (for-each-pair g ls)
19
20 (set! ls (cdr ls))
21
22 (let f ([i 1])
23 (unless (= i n)
24 (collect)
25 (cond
26 [(g) =>
27 (lambda (p)
28 (printf " [~s/~s]" i n)
29 (assert (eq? (cdr p) ls))
30 (set! ls (cdr ls))
31 (f (+ i 1)))]
32 [else (f i)])))
33 (assert (null? ls)))
34
35 (define (run-tests)
36 (test1)))
37