and-let-star.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ;;;; and-let-star.test --- Tests for Guile and-let-star module. -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2004, 2006 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 3 of the 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 GNU
  13. ;;;; 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, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. (define-module (test-suite test-and-let-star)
  19. #:use-module (test-suite lib)
  20. #:use-module (ice-9 and-let-star))
  21. ;;;
  22. ;;; and-let*
  23. ;;;
  24. (with-test-prefix "and-let*"
  25. (pass-if "cond-expand srfi-2"
  26. (cond-expand (srfi-2 #t)
  27. (else #f)))
  28. (with-test-prefix "no bindings"
  29. (pass-if "no result expression (gives #t)"
  30. (and-let* ()))
  31. (pass-if "result expression"
  32. (and-let* ()
  33. #t))
  34. (pass-if "two result expressions"
  35. (and-let* ()
  36. #f
  37. #t)))
  38. (with-test-prefix "one binding"
  39. (pass-if "no result expression (gives binding value)"
  40. (equal? (and-let* ((x 123))) 123))
  41. (pass-if "result expression"
  42. (and-let* ((x 123))
  43. #t))
  44. (pass-if "result variable"
  45. (and-let* ((x #t))
  46. x))
  47. (pass-if "two result expressions"
  48. (and-let* ((x 123))
  49. #f
  50. #t)))
  51. (with-test-prefix "one test"
  52. (pass-if "no result expression (gives test value)"
  53. (equal? (and-let* (( 123))) 123))
  54. (pass-if "result expression"
  55. (and-let* (( 123))
  56. #t))
  57. (pass-if "two result expressions"
  58. (and-let* (( 123))
  59. #f
  60. #t))))