Commits

kristianlm committed a37848a

bugfix set: fixes bug in set-fold and adds test

Comments (0)

Files changed (2)

 (define (set-fold set proc seed)
   (hash-table-fold
    (set-table set)
-   (lambda (k v s) (proc k seed))
+   (lambda (k v s) (proc k s))
    seed))
 
 (define (set-empty? set)
 
 (test-begin)
 
+(test-group
+ "set"
+
+ (let ((set (make-set)))
+   (for-each (cut set-insert! set <>) '(1 2 4))
+
+   (test '(4 2 1) (sort (set-members set) >))
+   (test 7 (set-fold set + 0))
+
+   (test #t (set-contains? set 2))
+   (set-remove! set 2)
+   (test '(4 1) (sort (set-members set) >))
+   (test #f (set-contains? set 2))
+
+   (test #f (set-empty? set))
+   (set-clear! set)
+   (test #t (set-empty? set))))
+
 (define (gc!!)
   (repeat 5 (gc #t)))