suspendable-ports.test 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ;;;; Scheme implementation of Guile ports -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2016 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software: you can redistribute it and/or modify
  6. ;;;; it under the terms of the GNU Lesser General Public License as
  7. ;;;; published by the Free Software Foundation, either version 3 of the
  8. ;;;; License, or (at your option) any later version.
  9. ;;;;
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;;;; GNU Lesser General Public License for more details.
  14. ;;;;
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library. If not, see
  17. ;;;; <http://www.gnu.org/licenses/>.
  18. (define-module (test-suite test-ports)
  19. #:use-module (ice-9 suspendable-ports))
  20. ;; Include tests from ports.test.
  21. (define-syntax import-uses
  22. (syntax-rules ()
  23. ((_) #t)
  24. ((_ #:use-module mod . uses)
  25. (begin (use-modules mod) (import-uses . uses)))))
  26. (define-syntax include-one
  27. (syntax-rules (define-module)
  28. ((_ (define-module mod . uses))
  29. (import-uses . uses))
  30. ((_ exp) exp)))
  31. (define-syntax include-tests
  32. (lambda (x)
  33. (syntax-case x ()
  34. ((include-tests file)
  35. (call-with-input-file (in-vicinity (getenv "TEST_SUITE_DIR")
  36. (syntax->datum #'file))
  37. (lambda (port)
  38. #`(begin
  39. . #,(let lp ()
  40. (let ((exp (read port)))
  41. (if (eof-object? exp)
  42. #'()
  43. (let ((exp (datum->syntax #'include-tests exp)))
  44. #`((include-one #,exp) . #,(lp))))))))
  45. #:guess-encoding #t)))))
  46. (install-suspendable-ports!)
  47. (include-tests "tests/ports.test")
  48. (include-tests "tests/rdelim.test")
  49. (include-tests "tests/r6rs-ports.test")
  50. (uninstall-suspendable-ports!)