test-char-prelude.scm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ;;; Copyright (C) 2023 Igalia, S.L.
  2. ;;;
  3. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  4. ;;; you may not use this file except in compliance with the License.
  5. ;;; You may obtain a copy of the License at
  6. ;;;
  7. ;;; http://www.apache.org/licenses/LICENSE-2.0
  8. ;;;
  9. ;;; Unless required by applicable law or agreed to in writing, software
  10. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  11. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. ;;; See the License for the specific language governing permissions and
  13. ;;; limitations under the License.
  14. ;;; Commentary:
  15. ;;;
  16. ;;; Tests for generated char-upcase, char-downcase, and so on.
  17. ;;;
  18. ;;; Code:
  19. (use-modules (srfi srfi-64)
  20. (ice-9 format)
  21. (test utils))
  22. (define (unary-char-procs-same? reference proc)
  23. (define success #t)
  24. (char-set-for-each
  25. (lambda (ch)
  26. (unless (eqv? (reference ch) (proc ch))
  27. (format (current-error-port) "mismatch for ~a on ~s: ~s vs ~s\n"
  28. reference ch (reference ch) (proc ch))
  29. (set! success #f)))
  30. char-set:full)
  31. success)
  32. (test-begin "test-char-prelude")
  33. (define-syntax-rule (define-char-prelude-procedures (name name*) ...)
  34. (define-values (name* ...)
  35. (let ()
  36. (include-from-path "hoot/char-prelude.scm")
  37. (values name ...))))
  38. (define-syntax-rule (test-char-prelude-procedures (name name*) ...)
  39. (begin
  40. (define-char-prelude-procedures (name name*) ...)
  41. (test-assert 'name (unary-char-procs-same? name name*))
  42. ...))
  43. (test-char-prelude-procedures
  44. (char-upcase char-upcase*)
  45. (char-downcase char-downcase*)
  46. (char-upper-case? char-upper-case?*)
  47. (char-lower-case? char-lower-case?*)
  48. (char-alphabetic? char-alphabetic?*)
  49. (char-numeric? char-numeric?*)
  50. (char-whitespace? char-whitespace?*))
  51. (test-end* "test-char-prelude")