srfi-1.test 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #! /bin/sh
  2. # -*-scheme-*-
  3. exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests srfi-1)' -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 srfi-1)
  24. #:use-module (srfi srfi-1)
  25. #:use-module (mes mes-0)
  26. #:use-module (mes test))
  27. (mes-use-module (srfi srfi-1))
  28. (mes-use-module (mes test))
  29. (pass-if "first dummy" #t)
  30. (pass-if-not "second dummy" #f)
  31. (pass-if-equal "fold"
  32. '(3 2 1)
  33. (fold cons '() '(1 2 3)))
  34. (pass-if-equal "fold-right"
  35. '(1 2 3)
  36. (fold-right cons '() '(1 2 3)))
  37. (pass-if-equal "unfold"
  38. '(4 3 2 1 foo)
  39. (unfold zero? identity 1- 4 (const '(foo))))
  40. (pass-if-equal "remove"
  41. '(1 3)
  42. (remove even? '(1 2 3)))
  43. (pass-if-equal "append-reverse"
  44. '(3 2 1 4 5 6)
  45. (append-reverse '(1 2 3) '(4 5 6)))
  46. (pass-if-equal "member lambda"
  47. '(4)
  48. (member 2 '(1 4) (lambda (x y) (even? y))))
  49. (pass-if-not "member ="
  50. (member 2 '(1 4) =))
  51. (pass-if-equal "append-map"
  52. '(0 0 1)
  53. (append-map iota '(1 2)))
  54. (pass-if-equal "fold-3"
  55. '(1 A a 2 B b 3 C c)
  56. (fold cons* '() '(3 2 1) '(C B A) '(c b a)))
  57. (pass-if-equal "fold-right-3"
  58. '(1 A a 2 B b 3 C c)
  59. (fold-right cons* '() '(1 2 3) '(A B C) '(a b c)))
  60. (result 'report)