getopt-long.test 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests getopt-long)' -s "$0" "$@"
  3. !#
  4. ;;; -*-scheme-*-
  5. ;;; GNU Mes --- Maxwell Equations of Software
  6. ;;; Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  7. ;;;
  8. ;;; This file is part of GNU Mes.
  9. ;;;
  10. ;;; GNU Mes is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Mes is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (tests getopt-long)
  23. #:use-module (mes mes-0)
  24. #:use-module (mes test)
  25. #:use-module (mes getopt-long))
  26. (cond-expand
  27. (mes
  28. (mes-use-module (mes getopt-long))
  29. (mes-use-module (mes test)))
  30. (else))
  31. (pass-if "first dummy" #t)
  32. (pass-if-not "second dummy" #f)
  33. (define option-spec '((help (single-char #\h))
  34. (include (single-char #\I) (value #t))
  35. (version (single-char #\V))))
  36. (pass-if-equal "getopt" '((() "bar"))
  37. (getopt-long '("foo" "bar") option-spec))
  38. (pass-if-equal "getopt2" '((() "bar" "baz"))
  39. (getopt-long '("foo" "bar" "baz") option-spec))
  40. (pass-if-equal "getopt --help" '((()) (help . #t))
  41. (getopt-long '("foo" "--help") option-spec))
  42. (pass-if-equal "getopt -hVI5d" '((()) (include . "5d") (version . #t) (help . #t))
  43. (getopt-long '("foo" "-hVI5d") option-spec))
  44. (pass-if-equal "getopt -I." '((()) (include . "."))
  45. (getopt-long '("foo" "-I.") option-spec))
  46. (pass-if-equal "getopt -I foo ..." '((()) (include . "lib") (include . "include"))
  47. (getopt-long '("foo" "-I" "include" "-I" "lib") option-spec))
  48. (result 'report)