-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.scm
executable file
·39 lines (32 loc) · 1.11 KB
/
tests.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!r6rs
;; Test with my as yet unfinished (quickcheck) library, see my github
;; account for the code
(import (quickcheck)
(rnrs)
(only (guile) random-state-from-platform)
(fectors))
(define (prop-update fector i o)
(-> (< i (fector-length fector))
(equal? o
(fector-ref (fector-set fector i o) i))))
(define (prop-update* fector i o)
(define len (fector-length fector))
(-> (< i len)
(let ((new-fector (fector-set fector i o)))
(for-all (lambda (x)
(or (= x i)
(equal? (fector-ref fector x)
(fector-ref new-fector x))))
(iota len)))))
(define (prop-conversion l)
(equal? l
(fector->list (list->fector l))))
(define (prop-length l)
(equal? (length l)
(fector-length (list->fector l))))
(define $fector ($=> ($list $integer) (lambda (x) (apply fector x))))
(random-state-from-platform)
(quickcheck prop-update $fector $integer $integer)
(quickcheck prop-update* $fector $integer $integer)
(quickcheck prop-conversion ($list $integer))
(quickcheck prop-length ($list $integer))