26.sld 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (define-library (srfi-tests 26)
  2. (export run-tests)
  3. (import
  4. (scheme base)
  5. (srfi 26)
  6. (srfi 64)
  7. (srfi-tests aux))
  8. (begin
  9. (define-tests run-tests "SRFI-26"
  10. ;; cut
  11. (test-equal '() ((cut list)))
  12. (test-equal '() ((cut list <...>)))
  13. (test-equal '(1) ((cut list 1)))
  14. (test-equal '(1) ((cut list <>) 1))
  15. (test-equal '(1) ((cut list <...>) 1))
  16. (test-equal '(1 2) ((cut list 1 2)))
  17. (test-equal '(1 2) ((cut list 1 <>) 2))
  18. (test-equal '(1 2) ((cut list 1 <...>) 2))
  19. (test-equal '(1 2 3 4) ((cut list 1 <...>) 2 3 4))
  20. (test-equal '(1 2 3 4) ((cut list 1 <> 3 <>) 2 4))
  21. (test-equal '(1 2 3 4 5 6) ((cut list 1 <> 3 <...>) 2 4 5 6))
  22. (test-equal '(ok) (let* ((x 'wrong) (y (cut list x))) (set! x 'ok) (y)))
  23. (test-equal 2 (let ((a 0))
  24. (map (cut + (begin (set! a (+ a 1)) a) <>)
  25. '(1 2))
  26. a))
  27. ;; cute
  28. (test-equal '() ((cute list)))
  29. (test-equal '() ((cute list <...>)))
  30. (test-equal '(1) ((cute list 1)))
  31. (test-equal '(1) ((cute list <>) 1))
  32. (test-equal '(1) ((cute list <...>) 1))
  33. (test-equal '(1 2) ((cute list 1 2)))
  34. (test-equal '(1 2) ((cute list 1 <>) 2))
  35. (test-equal '(1 2) ((cute list 1 <...>) 2))
  36. (test-equal '(1 2 3 4) ((cute list 1 <...>) 2 3 4))
  37. (test-equal '(1 2 3 4) ((cute list 1 <> 3 <>) 2 4))
  38. (test-equal '(1 2 3 4 5 6) ((cute list 1 <> 3 <...>) 2 4 5 6))
  39. (test-equal 1 (let ((a 0))
  40. (map (cute + (begin (set! a (+ a 1)) a) <>)
  41. '(1 2))
  42. a)))))