(use-modules (tests)
             (fibers)
             (unit-test)
             (knots parallelism)
             (knots promise))

(run-fibers-for-tests
 (lambda ()
   (let ((promises
          (map (lambda (i)
                 (fibers-delay
                  (lambda ()
                    (* i 2))))
               (iota 10))))

     (assert-equal
      #f
      (fibers-promise-result-available? (car promises)))

     (assert-equal
      90
      (apply + (fibers-map fibers-force promises)))

     (assert-equal
      #t
      (fibers-promise-result-available? (car promises))))))

(display "promise test finished successfully\n")
