procs.test 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ;;;; procss.test --- Procedures. -*- mode: scheme; coding: utf-8; -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2010 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-procs)
  19. #:use-module (srfi srfi-1)
  20. #:use-module (test-suite lib))
  21. (with-test-prefix "common procedures"
  22. (pass-if "identity"
  23. (eq? 'a (identity 'a)))
  24. (pass-if "const"
  25. (and (procedure? (const 'a))
  26. (eq? 'a ((const 'a)))
  27. (eq? 'a ((const 'a) 'b 'c 'd))))
  28. (pass-if "negate"
  29. (and (procedure? (negate number?))
  30. ((negate real?) 'dream)
  31. ((negate odd?) 0)))
  32. (with-test-prefix "compose"
  33. (pass-if "identity"
  34. (eq? 1+ (compose 1+)))
  35. (pass-if "simple"
  36. (= 2.0 ((compose sqrt 1+ 1+) 2)))
  37. (pass-if "multiple values"
  38. (equal? ((compose zip unzip2) '((1 2) (a b)))
  39. '((1 2) (a b))))))