test-char-prelude.scm 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;;; Copyright (C) 2023, 2024 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. (hoot config)
  21. (ice-9 format)
  22. (test utils))
  23. (define (unary-char-procs-same? reference proc)
  24. (define success #t)
  25. (char-set-for-each
  26. (lambda (ch)
  27. (unless (eqv? (reference ch) (proc ch))
  28. (format (current-error-port) "mismatch for ~a on ~s: ~s vs ~s\n"
  29. reference ch (reference ch) (proc ch))
  30. (set! success #f)))
  31. char-set:full)
  32. success)
  33. (test-begin "test-char-prelude")
  34. (eval-when (expand)
  35. (set! %load-path (append %stdlib-path %load-path)))
  36. (define-syntax-rule (define-char-prelude-procedures (name name*) ...)
  37. (define-values (name* ...)
  38. (let ()
  39. (include-from-path "hoot/char-prelude.scm")
  40. (values name ...))))
  41. (define-syntax-rule (test-char-prelude-procedures (name name*) ...)
  42. (begin
  43. (define-char-prelude-procedures (name name*) ...)
  44. (test-assert 'name (unary-char-procs-same? name name*))
  45. ...))
  46. (test-char-prelude-procedures
  47. (char-upcase char-upcase*)
  48. (char-downcase char-downcase*)
  49. (char-upper-case? char-upper-case?*)
  50. (char-lower-case? char-lower-case?*)
  51. (char-alphabetic? char-alphabetic?*)
  52. (char-numeric? char-numeric?*)
  53. (char-whitespace? char-whitespace?*))
  54. (test-end* "test-char-prelude")