test-vector-procs.scm 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (import
  2. (except (rnrs base) map vector-map)
  3. (only (guile)
  4. lambda* λ)
  5. ;; SRFI 64 - unit testing forms
  6. (srfi srfi-64)
  7. ;; SRFI 43 - vector procs
  8. (srfi srfi-43)
  9. ;; SRFI 1 - list procs
  10. (srfi srfi-1)
  11. ;; module under test
  12. (vector-procs))
  13. (test-begin "vector-procs-test")
  14. (test-group
  15. "vector-update-elements-test"
  16. (test-equal "vector-update-elements - 01"
  17. #((updated-a . 1)
  18. (updated-b . 2)
  19. (c . 3))
  20. (let ([current
  21. (list->vector
  22. (list (cons 'a 1)
  23. (cons 'b 2)
  24. (cons 'c 3)))]
  25. [updates
  26. (list->vector
  27. (list (cons 'updated-b 2)
  28. (cons 'updated-a 1)
  29. (cons 'other 6)))])
  30. (vector-update-elements
  31. current
  32. updates
  33. #:should-update? (λ (a b) (equal? (cdr a) (cdr b)))
  34. #:update-item (λ (a b) b)))))
  35. (test-end "vector-procs-test")