session.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;;;; session.test --- test suite for (ice-9 session) -*- scheme -*-
  2. ;;;; Jose Antonio Ortega Ruiz <jao@gnu.org> -- August 2010
  3. ;;;;
  4. ;;;; Copyright (C) 2010 Free Software Foundation, Inc.
  5. ;;;;
  6. ;;;; This library is free software; you can redistribute it and/or
  7. ;;;; modify it under the terms of the GNU Lesser General Public
  8. ;;;; License as published by the Free Software Foundation; either
  9. ;;;; version 3 of the License, or (at your option) any later version.
  10. ;;;;
  11. ;;;; This library is distributed in the hope that it will be useful,
  12. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;;;; Lesser General Public License for more details.
  15. ;;;;
  16. ;;;; You should have received a copy of the GNU Lesser General Public
  17. ;;;; License along with this library; if not, write to the Free Software
  18. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. ;;;; 02110-1301 USA
  20. (define-module (test-suite session)
  21. #:use-module (test-suite lib)
  22. #:use-module (ice-9 session))
  23. (define (find-module mod)
  24. (call/cc (lambda (k)
  25. (apropos-fold-all (lambda (m _)
  26. (and (not (module? m)) (k #f))
  27. (and (eq? m mod) (k #t)))
  28. #f))))
  29. (define (find-mod-name mod-name)
  30. (find-module (resolve-module mod-name #f #:ensure #f)))
  31. (with-test-prefix "apropos-fold-all"
  32. (pass-if "a root module: ice-9" (find-mod-name '(ice-9)))
  33. (pass-if "a child of test-suite" (find-mod-name '(test-suite lib)))
  34. (pass-if "a non-module" (not (find-mod-name '(ice-999-0))))
  35. (pass-if "a childish non-module" (not (find-mod-name '(ice-9 ice-999-0))))
  36. (pass-if "an anonymous module" (find-mod-name (module-name (make-module)))))
  37. (define (find-interface mod-name)
  38. (let* ((mod (resolve-module mod-name #f #:ensure #f))
  39. (ifc (and mod (module-public-interface mod))))
  40. (and ifc
  41. (call/cc (lambda (k)
  42. (apropos-fold-exported (lambda (i _)
  43. (and (eq? i ifc) (k #t)))
  44. #f))))))
  45. (with-test-prefix "apropos-fold-exported"
  46. (pass-if "a child of test-suite" (find-interface '(test-suite lib)))
  47. (pass-if "a child of ice-9" (find-interface '(ice-9 session))))