fluids.test 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #! /bin/sh
  2. # -*-scheme-*-
  3. exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests fluids)' -s "$0" "$@"
  4. !#
  5. ;;; -*-scheme-*-
  6. ;;; GNU Mes --- Maxwell Equations of Software
  7. ;;; Copyright © 2016 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  8. ;;;
  9. ;;; This file is part of GNU Mes.
  10. ;;;
  11. ;;; GNU Mes is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Mes is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (tests fluids)
  24. #:use-module (mes mes-0)
  25. #:use-module (mes test))
  26. (mes-use-module (mes fluids))
  27. (mes-use-module (mes test))
  28. (define a (make-fluid))
  29. (define b (make-fluid))
  30. (define c #f)
  31. (pass-if "fluid?" (fluid? a))
  32. (pass-if-not "fluid? not" (fluid? c))
  33. (pass-if-not "fluid-ref"
  34. (fluid-ref a))
  35. (pass-if "with-fluid*"
  36. (with-fluid* a #t (lambda () (fluid-ref a))))
  37. (pass-if-not "with-fluid* reset"
  38. (begin
  39. (with-fluid* a #t (lambda () (fluid-ref a)))
  40. (fluid-ref a)))
  41. ;; (pass-if-equal "with fluids*"
  42. ;; 0 (with-fluids* (list a b) '(0 1)
  43. ;; (lambda () (fluid-ref a))))
  44. (pass-if-eq "with-fluids"
  45. 0 (with-fluids ((a 1)
  46. (a 2)
  47. (a 3))
  48. (fluid-set! a 0)
  49. (fluid-ref a)))
  50. (pass-if-eq "with-fluids"
  51. #f (begin
  52. (with-fluids ((a 1)
  53. (b 2))
  54. (fluid-set! a 0)
  55. (display "X:") (display (fluid-ref a)) (newline))
  56. (fluid-ref a)))
  57. (result 'report)