srfi-108-test.scm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. (test-begin "srfi-108")
  2. ;; Some tests are based on Racket/Scribble documentation.
  3. (require "test-utils.scm")
  4. (define-syntax $construct$:doc
  5. (syntax-rules ()
  6. ((_ arg ...)
  7. ;; FIXME: #<div>&[arg ...]</>)))
  8. ($xml-element$ () ($resolve-qname$ div) arg ...))))
  9. (define-syntax $construct$:chapter
  10. (syntax-rules ()
  11. ((_ arg ...)
  12. ;; FIXME: #<h1>&[arg ...]</>)))
  13. ($xml-element$ () ($resolve-qname$ h1) arg ...))))
  14. (define-syntax $construct$:section
  15. (syntax-rules ()
  16. ((_ arg ...)
  17. ;; FIXME: #<h2>&[arg ...]</>)))
  18. ($xml-element$ () ($resolve-qname$ h2) arg ...))))
  19. (define-syntax $construct$:itemlist
  20. (syntax-rules ()
  21. ((_ arg ...)
  22. ;; FIXME: #<ul>&[arg ...]</>)))
  23. ($xml-element$ () ($resolve-qname$ ul) arg ...))))
  24. (define-syntax $construct$:item
  25. (syntax-rules ()
  26. ((_ arg ...)
  27. ;; FIXME: #<li>&[arg ...]</>)))
  28. ($xml-element$ () ($resolve-qname$ li) arg ...))))
  29. (define-syntax $construct$:emph
  30. (syntax-rules ()
  31. ((_ arg ...)
  32. ;; FIXME: #<em>&[arg ...]</>)))
  33. ($xml-element$ () ($resolve-qname$ em) arg ...))))
  34. (xtest &emph{abc}
  35. '($construct$:emph "abc")
  36. &{<em>abc</em>})
  37. (xtest &emph{abc&["n1" 3 "m2"]z}
  38. '($construct$:emph "abc" $<<$ "n1" 3 "m2" $>>$ "z")
  39. &{<em>abcn13m2z</em>})
  40. (xtest &emph{abc&(+ 3 4)z}
  41. '($construct$:emph "abc" $<<$ (+ 3 4) $>>$ "z")
  42. &{<em>abc7z</em>})
  43. (xtest &itemlist[&item{We have cookies for you.}
  44. &item{If you want to eat a cookie,
  45. you must bring your own straw.}]
  46. '($construct$:itemlist
  47. ($construct$:item "We have cookies for you.")
  48. ($construct$:item "If you want to eat a cookie,
  49. you must bring your own straw.")
  50. $>>$)
  51. "<ul><li>We have cookies for you.</li><li>If you want to eat a cookie,\n you must bring your own straw.</li></ul>")
  52. (define (make-foo #!rest args) (apply arglist 'FOO args))
  53. (define-simple-constructor foo make-foo)
  54. (test-equal '(FOO "abc7z")
  55. &foo{abc&(+ 3 4)z})
  56. (test-equal '(FOO 3 20 "abc7z")
  57. &foo[(+ 1 2) (* 4 5)]{abc&(+ 3 4)z})
  58. (test-equal '(FOO id: "n7" "7abc")
  59. &foo[id: "n7"]{&(+ 3 4)abc})
  60. (define-syntax $construct$:bar
  61. (syntax-rules ()
  62. ((_ . args) (list 'BAR . args))))
  63. (test-equal '(BAR "abc" "" 7 "" "z")
  64. &bar{abc&(+ 3 4)z})
  65. (test-equal '(BAR 3 20 "" "abc" "" 7 "" "z")
  66. &bar[(+ 1 2) (* 4 5)]{abc&(+ 3 4)z})
  67. (test-end)