procprop.test 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;;; procprop.test --- Procedure properties -*- mode: scheme; coding: utf-8; -*-
  2. ;;;; Ludovic Courtès <ludo@gnu.org>
  3. ;;;;
  4. ;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  5. ;;;;
  6. ;;;; This library is free software; you can redistribute it and/or
  7. ;;;; modify it under the terms of the GNU Lesser General Public
  8. ;;;; License as published by the Free Software Foundation; either
  9. ;;;; version 3 of the License, or (at your option) any later version.
  10. ;;;;
  11. ;;;; This library is distributed in the hope that it will be useful,
  12. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;;;; Lesser General Public License for more details.
  15. ;;;;
  16. ;;;; You should have received a copy of the GNU Lesser General Public
  17. ;;;; License along with this library; if not, write to the Free Software
  18. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. (define-module (test-procpop)
  20. :use-module (test-suite lib))
  21. (with-test-prefix "procedure-name"
  22. (pass-if "simple subr"
  23. (eq? 'display (procedure-name display)))
  24. (pass-if "gsubr"
  25. (eq? 'hashq-ref (procedure-name hashq-ref)))
  26. (pass-if "from eval"
  27. (eq? 'foobar (procedure-name
  28. (eval '(begin (define (foobar) #t) foobar)
  29. (current-module))))))
  30. (with-test-prefix "procedure-arity"
  31. (pass-if "simple subr"
  32. (equal? (procedure-minimum-arity display)
  33. '(1 1 #f)))
  34. (pass-if "gsubr"
  35. (equal? (procedure-minimum-arity hashq-ref)
  36. '(2 1 #f)))
  37. (pass-if "port-closed?"
  38. (equal? (procedure-minimum-arity port-closed?)
  39. '(1 0 #f)))
  40. (pass-if "apply"
  41. (equal? (procedure-minimum-arity apply)
  42. '(2 0 #t)))
  43. (pass-if "cons*"
  44. (equal? (procedure-minimum-arity cons*)
  45. '(1 0 #t)))
  46. (pass-if "list"
  47. (equal? (procedure-minimum-arity list)
  48. '(0 0 #t)))
  49. (pass-if "fixed, eval"
  50. (equal? (procedure-minimum-arity (eval '(lambda (a b) #t)
  51. (current-module)))
  52. '(2 0 #f)))
  53. (pass-if "rest, eval"
  54. (equal? (procedure-minimum-arity (eval '(lambda (a b . c) #t)
  55. (current-module)))
  56. '(2 0 #t)))
  57. (pass-if "opt, eval"
  58. (equal? (procedure-minimum-arity (eval '(lambda* (a b #:optional c) #t)
  59. (current-module)))
  60. '(2 1 #f))))