Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 26 lines (19 sloc) 0.725 kB
da8646c @mcandre fixing imports
authored
1 (module cluckcheck (gen-int gen-bool gen-char gen-list gen-string for-all)
d1ebf13 @mcandre debugging module
authored
2 (import scheme chicken extras)
bb0d9d3 @mcandre gen-list and gen-string working
authored
3
e810a2c @mcandre simplified
authored
4 (use srfi-1) ; lists
eb7aa49 @mcandre first commit
authored
5
d1ebf13 @mcandre debugging module
authored
6 (define (gen-int)
7 (random 256))
cb45b5a @mcandre gen-int and gen-bool working
authored
8
d1ebf13 @mcandre debugging module
authored
9 (define (gen-bool)
10 (= (random 2) 0))
f26c6bb @mcandre gen-char working
authored
11
d1ebf13 @mcandre debugging module
authored
12 (define (gen-char)
13 (integer->char (random 128)))
bb0d9d3 @mcandre gen-list and gen-string working
authored
14
d1ebf13 @mcandre debugging module
authored
15 (define (gen-list gen)
16 (map (lambda (x) (gen)) (iota (random 100))))
bb0d9d3 @mcandre gen-list and gen-string working
authored
17
d1ebf13 @mcandre debugging module
authored
18 (define (gen-string)
19 (list->string (gen-list gen-char)))
20
21 (define (for-all property . generators)
22 (let ((values (map (lambda (x) (map (lambda (f) (f)) generators)) (iota 100))))
23 (let ((failure (find (lambda (vs) (not (apply property vs))) values)))
24 (if (list? failure)
25 (display (format "*** Failed!\n~a\n" failure))
26 (display (format "+++ OK, passed 100 tests\n")))))))
Something went wrong with that request. Please try again.