63 lines
1.3 KiB
Scheme
63 lines
1.3 KiB
Scheme
(use-modules (tests)
|
|
(fibers)
|
|
(unit-test)
|
|
(knots parallelism))
|
|
|
|
;; Test fibers-map
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(assert-equal
|
|
1122
|
|
(apply + (fibers-map
|
|
(lambda (i)
|
|
(* 2 i))
|
|
(iota 34))))))
|
|
|
|
;; Test fibers-batch-map with a large batch size
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(assert-equal
|
|
1122
|
|
(apply + (fibers-batch-map
|
|
(lambda (i)
|
|
(* 2 i))
|
|
100
|
|
(iota 34))))))
|
|
|
|
;; Test fibers-map with an empty list
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(fibers-map identity '())))
|
|
|
|
;; Test fibers-map with an empty vector
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(fibers-map identity #())))
|
|
|
|
;; Test fibers-map with vectors
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(assert-equal
|
|
1122
|
|
(apply + (vector->list
|
|
(fibers-map
|
|
(lambda (i)
|
|
(* 2 i))
|
|
(list->vector (iota 34))))))))
|
|
|
|
;; Test fibers-for-each
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(fibers-for-each
|
|
(lambda (i)
|
|
(* 2 i))
|
|
(iota 34))))
|
|
|
|
;; Test fibers-map-with-progress with an empty list
|
|
(run-fibers-for-tests
|
|
(lambda ()
|
|
(fibers-map-with-progress
|
|
identity
|
|
'(()))))
|
|
|
|
(display "parallelism test finished successfully\n")
|