colloquia-test.lisp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. (in-package #:colloquia)
  2. #+nil (assert (equal (with-input-from-string (in "Titulus: De incomparabili heroe Joanne Reuchlino in divorum numerum relato.
  3. Personæ: Pompilius, Brassicanus.")
  4. (coll-read-header in))
  5. '((TITULUS "De incomparabili heroe Joanne Reuchlino in divorum numerum relato.")
  6. (PERSONAE ("Pompilius" "Brassicanus")))
  7. ))
  8. (assert (equalp (parse-cue '((bar-group "Br") "At" "idem," (slash-group "ne") "sis" star "inscius,"))
  9. (make-cue "Br" (make-rich-text
  10. (list (make-rich-word "At")
  11. (make-rich-word "idem,")
  12. (make-rich-word "ne" 'i)
  13. (make-rich-word "sis")
  14. 'note-sign
  15. (make-rich-word "inscius,"))))
  16. ))
  17. (assert (string= (with-output-to-string (*tex-stream*)
  18. (to-tex "tu & ego"))
  19. "tu \\& ego"))
  20. (assert (string= (with-output-to-string (*tex-stream*)
  21. (to-tex (make-cue "Po" (make-rich-text (list (make-rich-word "Unde")
  22. (make-rich-word "nobis" 'i)
  23. (make-rich-word "petasatus?" 'i))))))
  24. "\\textsc{Po}. Unde \\emph{nobis petasatus?}
  25. "
  26. ))
  27. (assert (equal (with-input-from-string (in "wibble wobble /foo bar baz/ qux")
  28. (loop for token = (coll-read in)
  29. while token
  30. collect token))
  31. '("wibble" "wobble" (SLASH-GROUP "foo" "bar" "baz") "qux")
  32. ))
  33. (assert (equal (with-input-from-string (in "foo bar baz/ qux")
  34. (coll-read-delimited #\/ in))
  35. '("foo" "bar" "baz")))
  36. (assert (equal (with-input-from-string (in "foo ba.r baz. qux")
  37. (coll-read-delimited #\. in))
  38. '("foo" "ba")
  39. ))
  40. (assert (equal (with-input-from-string
  41. (s "
  42. foo
  43. bar
  44. baz
  45. `
  46. qux")
  47. (coll-read-delimited-lines "`" s)
  48. ) '("foo" "bar" "baz")))
  49. (assert (equal (with-input-from-string
  50. (s "
  51. foo
  52. bar
  53. baz
  54. ```
  55. qux")
  56. (coll-read-delimited-lines "```" s)
  57. )
  58. '("foo" "bar" "baz")
  59. ))
  60. (assert (equalp (multiple-value-list (parse-verse '((backquote-group "foo bar baz" "*qux quux") "wibble" "wobble")))
  61. (list (make-verse (list (make-rich-text (list (make-rich-word "foo")
  62. (make-rich-word "bar")
  63. (make-rich-word "baz")))
  64. (make-rich-text (list 'note-sign
  65. (make-rich-word "qux")
  66. (make-rich-word "quux")))))
  67. '("wibble" "wobble"))))
  68. (assert (equalp (parse-rich-text '("foo" (slash-group "bar" star "baz") "qux"))
  69. (make-rich-text (list (make-rich-word "foo")
  70. (make-rich-word "bar" 'i)
  71. 'note-sign
  72. (make-rich-word "baz" 'i)
  73. (make-rich-word "qux")))))