12.tests.scm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (import
  2. (scheme base)
  3. (scheme load)
  4. (srfi 64))
  5. (load "./12.exercises.scm")
  6. (define (test-exercise-12.1)
  7. (let ((result (exercise-12.1)))
  8. (test-equal "Exercise 12.1" result 10)))
  9. (define (test-exercise-12.22)
  10. (let ((result (exercise-12.22)))
  11. (for-each (lambda (p)
  12. (define key (car p))
  13. (define expected-v (cdr p))
  14. (send result
  15. 'lookup
  16. key
  17. (lambda (s)
  18. (define test-name (string-append "Exercise 12.22 - " key))
  19. (test-equal test-name expected-v s))
  20. (lambda ()
  21. (error "key not found" key))))
  22. '(("this" . 2)
  23. ("hash" . 4)
  24. ("table" . 2)
  25. ("is" . 1)
  26. ("inefficient" . 1)
  27. ("as" . 2)
  28. ("a" . 1)
  29. ("bucket" . 1)))))
  30. (define (test-12)
  31. (test-begin "Chapter 12 Exercises test suite")
  32. (test-exercise-12.1)
  33. (test-exercise-12.22)
  34. (test-end))
  35. (test-12)