Test concurrent-filter-map
[tt.git] / tt.rkt
diff --git a/tt.rkt b/tt.rkt
index b11364f..b691fd0 100644 (file)
--- a/tt.rkt
+++ b/tt.rkt
 (require http-client)
 (require rfc3339-old)
 
+(module+ test
+  (require rackunit))
+
 (struct msg  (ts_epoch ts_rfc3339 nick uri text))
 (struct feed (nick uri))
 
 (define (concurrent-filter-map num_workers f xs)
+  ; TODO preserve order of elements OR communicate that reorder is expected
   ; TODO switch from mailboxes to channels
   (define (make-worker id f)
     (define parent (current-thread))
   (for-each thread-wait threads)
   results)
 
+(module+ test
+  (define n-workers 10)
+  (define given (list
+                  (λ (x) (if (even? x) x #f))
+                  (range 11)))
+  (check-equal?
+    (sort (apply concurrent-filter-map (cons n-workers given)) <)
+    (sort (apply            filter-map                 given ) <)))
+
 (define (msg-print out-format odd msg)
   (printf
     (match out-format
This page took 0.022101 seconds and 4 git commands to generate.