lazy-test.scm 964 B

12345678910111213141516171819202122232425262728
  1. (test-begin "lazy")
  2. (test-equal 123 (+ (delay 100) (delay 23)))
  3. (test-equal 23 ((delay +) (delay 20) (delay 3)))
  4. (test-equal 23 ((future +) (future 20) (future 3)))
  5. (test-equal 33 (vector-ref #(11 22 33) (delay 2)))
  6. (test-equal 33 (vector-ref (delay #(11 22 33)) 2))
  7. (test-equal 33 (vector-ref (delay #(11 22 33)) (delay 2)))
  8. (test-equal 33 ((delay vector-ref) (delay #(11 22 33)) (delay 2)))
  9. (test-equal 33 ((delay #(11 22 33)) (delay 2)))
  10. (test-equal 33 ((delay #(11 22 33)) 2))
  11. (test-equal 33 (#(11 22 33) (delay 2)))
  12. (test-equal #\B (string-ref (delay "ABC") 1))
  13. (test-equal #\B (string-ref "ABC" (delay 1)))
  14. (test-equal #\B (string-ref (delay "ABC") (delay 1)))
  15. (let* ((v1 (delay (vector 3 4 5)))
  16. (v2 ::vector v1))
  17. (test-equal 4 (v2 1)))
  18. (define v3 ::promise (future (cons 3 4)))
  19. (test-equal 4 (cdr v3))
  20. (define v4 ::promise[pair] (delay (cons 4 5)))
  21. (test-equal 5 (cdr v4))
  22. ;; error: (define v5 ::promise[integer] (delay (cons 4 5)))
  23. (test-end)