cwv.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #! /bin/sh
  2. # -*-scheme-*-
  3. exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests cwv)' -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 cwv)
  24. #:use-module (mes mes-0)
  25. #:use-module (mes test))
  26. (mes-use-module (mes scm))
  27. (mes-use-module (mes test))
  28. (if (not guile-1.8?)
  29. (pass-if "values" (seq? (values 0 1) 0)))
  30. (if (not guile-1.8?)
  31. (pass-if "values 2" (seq? ((lambda (x) x) (values 1 2 3)) 1)))
  32. (if (not guile-1.8?)
  33. (pass-if "values 3" (seq? 1 ((lambda (x) x) (values 1 2 3)))))
  34. (pass-if "call-with-values" (seq? (call-with-values (lambda () (values 1 2 3))
  35. (lambda (a b c) (+ a b c)))
  36. 6))
  37. (pass-if-equal "lambda"
  38. '(1 2 3 4 5)
  39. ((lambda (x)
  40. (x 1 2 3 4 5))
  41. (lambda (one two three four five)
  42. (list one two three four five))))
  43. (pass-if-equal "values 5"
  44. '(1 2 3 4 5)
  45. (call-with-values
  46. (lambda ()
  47. (values 1 2 3 4 5))
  48. (lambda (one two three four five)
  49. (list one two three four five))))
  50. (pass-if-equal "values rests"
  51. 1
  52. (call-with-values
  53. (lambda ()
  54. (values 1 2 3 4 5))
  55. (lambda (one . rest)
  56. one)))
  57. (pass-if-equal "values 4a 4b"
  58. '(1 2 3 four-a 5)
  59. ((lambda (one two three four five)
  60. (append
  61. (list one two three)
  62. (call-with-values
  63. (lambda () four)
  64. (lambda (4a . 4b)
  65. ;;(cons 4a 4b) FIXME: non-compliancy?
  66. (list 4a)
  67. ))
  68. (list five)))
  69. 1 2 3 (values 'four-a 'four-b) 5))
  70. (result 'report)