texinfo.serialize.test 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. ;;;; texinfo.serialize.test -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2010, 2013 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 3 of the License, or (at your option) any later version.
  9. ;;;;
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. ;;;; Lesser General Public License for more details.
  14. ;;;;
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library; if not, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. ;;; Commentary:
  19. ;;
  20. ;; Unit tests for (texinfo serialize).
  21. ;;
  22. ;;; Code:
  23. (define-module (test-suite texinfo-serialize)
  24. #:use-module (test-suite lib)
  25. #:use-module (texinfo serialize))
  26. (with-test-prefix "test-serialize"
  27. (define (assert-serialize stexi str)
  28. (pass-if-equal stexi str (stexi->texi stexi)))
  29. (assert-serialize '(para)
  30. "
  31. ")
  32. (assert-serialize '(para "foo")
  33. "foo
  34. ")
  35. (assert-serialize '(var "foo")
  36. "@var{foo}")
  37. ;; i don't remember why braces exists, but as long as it does, a test
  38. ;; is in order
  39. (assert-serialize '(*braces* "foo")
  40. "@{foo@}")
  41. (assert-serialize '(value (% (key "foo")))
  42. "@value{foo}")
  43. (assert-serialize '(ref (% (node "foo")))
  44. "@ref{foo}")
  45. (assert-serialize '(ref (% (node "foo") (name "bar")))
  46. "@ref{foo,bar}")
  47. (assert-serialize '(ref (% (node "foo") (name "bar")
  48. (section "qux") (info-file "xyzzy")
  49. (manual "zarg")))
  50. "@ref{foo,bar,qux,xyzzy,zarg}")
  51. (assert-serialize '(ref (% (section "qux") (info-file "xyzzy")
  52. (node "foo") (name "bar")
  53. (manual "zarg")))
  54. "@ref{foo,bar,qux,xyzzy,zarg}")
  55. (assert-serialize '(ref (% (node "foo")
  56. (manual "zarg")))
  57. "@ref{foo,,,,zarg}")
  58. (assert-serialize '(dots) "@dots{}")
  59. (assert-serialize '(node (% (name "foo")))
  60. "@node foo
  61. ")
  62. (assert-serialize '(node (% (name "foo bar")))
  63. "@node foo bar
  64. ")
  65. (assert-serialize '(node (% (name "foo bar") (next "baz")))
  66. "@node foo bar, baz
  67. ")
  68. (assert-serialize '(title "Foo")
  69. "@title Foo
  70. ")
  71. (assert-serialize '(title "Foo is a " (var "bar"))
  72. "@title Foo is a @var{bar}
  73. ")
  74. (assert-serialize '(title "Foo is a " (var "bar") " baz")
  75. "@title Foo is a @var{bar} baz
  76. ")
  77. (assert-serialize '(cindex (% (entry "Bar baz, foo")))
  78. "@cindex Bar baz, foo
  79. ")
  80. ;; there is a space after @iftex, doesn't matter tho
  81. (assert-serialize '(iftex
  82. (para "This is only for tex.")
  83. (para "Note. Foo."))
  84. "@iftex
  85. This is only for tex.
  86. Note. Foo.
  87. @end iftex
  88. ")
  89. (assert-serialize '(defun (% (name "frob"))
  90. (para "foo?"))
  91. "@defun frob
  92. foo?
  93. @end defun
  94. ")
  95. (assert-serialize '(defun (% (name "frob") (arguments "bar"))
  96. (para "foo?"))
  97. "@defun frob bar
  98. foo?
  99. @end defun
  100. ")
  101. (assert-serialize '(defun (% (name "frob") (arguments "bar" " " "baz"))
  102. (para "foo?"))
  103. "@defun frob bar baz
  104. foo?
  105. @end defun
  106. ")
  107. (assert-serialize '(defun (% (name "frob") (arguments (var "bar")))
  108. (para "foo?"))
  109. "@defun frob @var{bar}
  110. foo?
  111. @end defun
  112. ")
  113. (assert-serialize '(defunx (% (name "frob") (arguments (var "bar"))))
  114. "@defunx frob @var{bar}
  115. ")
  116. (assert-serialize '(table (% (formatter (var)))
  117. (entry (% (heading "Foo bar " (code "baz")))
  118. (para "Frobate")
  119. (para "zzzzz")))
  120. "@table @var
  121. @item Foo bar @code{baz}
  122. Frobate
  123. zzzzz
  124. @end table
  125. ")
  126. (assert-serialize '(verbatim "foo")
  127. "@verbatim
  128. foo
  129. @end verbatim
  130. ")
  131. (assert-serialize '(deffnx (% (name "foo") (category "bar")))
  132. "@deffnx bar foo
  133. ")
  134. (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "x" " " "y")))
  135. "@deffnx bar foo x y
  136. ")
  137. (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "(" "x" " " (code "int") ")")))
  138. "@deffnx bar foo (x @code{int})
  139. ")
  140. (assert-serialize '(deffnx (% (name "foo") (category "bar baz") (arguments "(" "x" " " (code "int") ")")))
  141. "@deffnx {bar baz} foo (x @code{int})
  142. ")
  143. (assert-serialize '(deffnx (% (name "foo") (category (code "bar") " baz") (arguments "(" "x" " " (code "int") ")")))
  144. "@deffnx {@code{bar} baz} foo (x @code{int})
  145. ")
  146. )