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
19;;; Commentary:
20;;
21;; Unit tests for (texinfo serialize).
22;;
23;;; Code:
24
25(define-module (test-suite texinfo-serialize)
26  #:use-module (test-suite lib)
27  #:use-module (texinfo serialize))
28
29(with-test-prefix "test-serialize"
30  (define (assert-serialize stexi str)
31    (pass-if-equal stexi str (stexi->texi stexi)))
32
33  (assert-serialize '(para)
34                    "
35
36")
37
38  (assert-serialize '(para "foo")
39                    "foo
40
41")
42
43  (assert-serialize '(var "foo")
44                    "@var{foo}")
45
46
47  ;; i don't remember why braces exists, but as long as it does, a test
48  ;; is in order
49  (assert-serialize '(*braces* "foo")
50                    "@{foo@}")
51
52  (assert-serialize '(value (% (key "foo")))
53                    "@value{foo}")
54
55  (assert-serialize '(ref (% (node "foo")))
56                    "@ref{foo}")
57  (assert-serialize '(ref (% (node "foo") (name "bar")))
58                    "@ref{foo,bar}")
59  (assert-serialize '(ref (% (node "foo") (name "bar")
60                             (section "qux") (info-file "xyzzy")
61                             (manual "zarg")))
62                    "@ref{foo,bar,qux,xyzzy,zarg}")
63  (assert-serialize '(ref (% (section "qux") (info-file "xyzzy")
64                             (node "foo") (name "bar")
65                             (manual "zarg")))
66                    "@ref{foo,bar,qux,xyzzy,zarg}")
67  (assert-serialize '(ref (% (node "foo")
68                             (manual "zarg")))
69                    "@ref{foo,,,,zarg}")
70
71  (assert-serialize '(dots) "@dots{}")
72
73  (assert-serialize '(node (% (name "foo")))
74                    "@node foo
75")
76
77  (assert-serialize '(node (% (name "foo bar")))
78                    "@node foo bar
79")
80  (assert-serialize '(node (% (name "foo bar") (next "baz")))
81                    "@node foo bar, baz
82")
83
84  (assert-serialize '(title "Foo")
85                    "@title Foo
86")
87  (assert-serialize '(title "Foo is a " (var "bar"))
88                    "@title Foo is a @var{bar}
89")
90
91  (assert-serialize '(title "Foo is a " (var "bar") " baz")
92                    "@title Foo is a @var{bar} baz
93")
94
95  (assert-serialize '(cindex (% (entry "Bar baz, foo")))
96                    "@cindex Bar baz, foo
97")
98
99  ;; there is a space after @iftex, doesn't matter tho
100  (assert-serialize '(iftex
101                      (para "This is only for tex.")
102                      (para "Note. Foo."))
103                    "@iftex
104This is only for tex.
105
106Note.  Foo.
107
108@end iftex
109
110")
111
112  (assert-serialize '(defun (% (name "frob"))
113                       (para "foo?"))
114                    "@defun frob
115foo?
116
117@end defun
118
119")
120
121  (assert-serialize '(defun (% (name "frob") (arguments "bar"))
122                       (para "foo?"))
123                    "@defun frob bar
124foo?
125
126@end defun
127
128")
129
130  (assert-serialize '(defun (% (name "frob") (arguments "bar" " " "baz"))
131                       (para "foo?"))
132                    "@defun frob bar baz
133foo?
134
135@end defun
136
137")
138
139  (assert-serialize '(defun (% (name "frob") (arguments (var "bar")))
140                       (para "foo?"))
141                    "@defun frob @var{bar}
142foo?
143
144@end defun
145
146")
147
148  (assert-serialize '(defunx (% (name "frob") (arguments (var "bar"))))
149                    "@defunx frob @var{bar}
150")
151
152  (assert-serialize '(table (% (formatter (var)))
153                            (entry (% (heading "Foo bar " (code "baz")))
154                                   (para "Frobate")
155                                   (para "zzzzz")))
156                    "@table @var
157@item Foo bar @code{baz}
158Frobate
159
160zzzzz
161
162@end table
163
164")
165
166  (assert-serialize '(verbatim "foo")
167                    "@verbatim
168foo
169@end verbatim
170
171")
172
173  (assert-serialize '(deffnx (% (name "foo") (category "bar")))
174                    "@deffnx bar foo
175")
176
177  (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "x" " " "y")))
178                    "@deffnx bar foo x y
179")
180
181  (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "(" "x" " " (code "int") ")")))
182                    "@deffnx bar foo (x @code{int})
183")
184
185  (assert-serialize '(deffnx (% (name "foo") (category "bar baz") (arguments "(" "x" " " (code "int") ")")))
186                    "@deffnx {bar baz} foo (x @code{int})
187")
188
189  (assert-serialize '(deffnx (% (name "foo") (category (code "bar") " baz") (arguments "(" "x" " " (code "int") ")")))
190                    "@deffnx {@code{bar} baz} foo (x @code{int})
191")
192  )
193