123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- ;;;; texinfo.serialize.test -*- scheme -*-
- ;;;;
- ;;;; Copyright (C) 2010, 2013 Free Software Foundation, Inc.
- ;;;;
- ;;;; This library is free software; you can redistribute it and/or
- ;;;; modify it under the terms of the GNU Lesser General Public
- ;;;; License as published by the Free Software Foundation; either
- ;;;; version 3 of the License, or (at your option) any later version.
- ;;;;
- ;;;; This library is distributed in the hope that it will be useful,
- ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- ;;;; Lesser General Public License for more details.
- ;;;;
- ;;;; You should have received a copy of the GNU Lesser General Public
- ;;;; License along with this library; if not, write to the Free Software
- ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ;;; Commentary:
- ;;
- ;; Unit tests for (texinfo serialize).
- ;;
- ;;; Code:
- (define-module (test-suite texinfo-serialize)
- #:use-module (test-suite lib)
- #:use-module (texinfo serialize))
- (with-test-prefix "test-serialize"
- (define (assert-serialize stexi str)
- (pass-if-equal stexi str (stexi->texi stexi)))
- (assert-serialize '(para)
- "
- ")
- (assert-serialize '(para "foo")
- "foo
- ")
- (assert-serialize '(var "foo")
- "@var{foo}")
-
- ;; i don't remember why braces exists, but as long as it does, a test
- ;; is in order
- (assert-serialize '(*braces* "foo")
- "@{foo@}")
- (assert-serialize '(value (% (key "foo")))
- "@value{foo}")
- (assert-serialize '(ref (% (node "foo")))
- "@ref{foo}")
- (assert-serialize '(ref (% (node "foo") (name "bar")))
- "@ref{foo,bar}")
- (assert-serialize '(ref (% (node "foo") (name "bar")
- (section "qux") (info-file "xyzzy")
- (manual "zarg")))
- "@ref{foo,bar,qux,xyzzy,zarg}")
- (assert-serialize '(ref (% (section "qux") (info-file "xyzzy")
- (node "foo") (name "bar")
- (manual "zarg")))
- "@ref{foo,bar,qux,xyzzy,zarg}")
- (assert-serialize '(ref (% (node "foo")
- (manual "zarg")))
- "@ref{foo,,,,zarg}")
- (assert-serialize '(dots) "@dots{}")
- (assert-serialize '(node (% (name "foo")))
- "@node foo
- ")
- (assert-serialize '(node (% (name "foo bar")))
- "@node foo bar
- ")
- (assert-serialize '(node (% (name "foo bar") (next "baz")))
- "@node foo bar, baz
- ")
- (assert-serialize '(title "Foo")
- "@title Foo
- ")
- (assert-serialize '(title "Foo is a " (var "bar"))
- "@title Foo is a @var{bar}
- ")
- (assert-serialize '(title "Foo is a " (var "bar") " baz")
- "@title Foo is a @var{bar} baz
- ")
- (assert-serialize '(cindex (% (entry "Bar baz, foo")))
- "@cindex Bar baz, foo
- ")
- ;; there is a space after @iftex, doesn't matter tho
- (assert-serialize '(iftex
- (para "This is only for tex.")
- (para "Note. Foo."))
- "@iftex
- This is only for tex.
- Note. Foo.
- @end iftex
- ")
- (assert-serialize '(defun (% (name "frob"))
- (para "foo?"))
- "@defun frob
- foo?
- @end defun
- ")
- (assert-serialize '(defun (% (name "frob") (arguments "bar"))
- (para "foo?"))
- "@defun frob bar
- foo?
- @end defun
- ")
- (assert-serialize '(defun (% (name "frob") (arguments "bar" " " "baz"))
- (para "foo?"))
- "@defun frob bar baz
- foo?
- @end defun
- ")
- (assert-serialize '(defun (% (name "frob") (arguments (var "bar")))
- (para "foo?"))
- "@defun frob @var{bar}
- foo?
- @end defun
- ")
- (assert-serialize '(defunx (% (name "frob") (arguments (var "bar"))))
- "@defunx frob @var{bar}
- ")
- (assert-serialize '(table (% (formatter (var)))
- (entry (% (heading "Foo bar " (code "baz")))
- (para "Frobate")
- (para "zzzzz")))
- "@table @var
- @item Foo bar @code{baz}
- Frobate
- zzzzz
- @end table
- ")
- (assert-serialize '(verbatim "foo")
- "@verbatim
- foo
- @end verbatim
- ")
- (assert-serialize '(deffnx (% (name "foo") (category "bar")))
- "@deffnx bar foo
- ")
- (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "x" " " "y")))
- "@deffnx bar foo x y
- ")
- (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "(" "x" " " (code "int") ")")))
- "@deffnx bar foo (x @code{int})
- ")
- (assert-serialize '(deffnx (% (name "foo") (category "bar baz") (arguments "(" "x" " " (code "int") ")")))
- "@deffnx {bar baz} foo (x @code{int})
- ")
- (assert-serialize '(deffnx (% (name "foo") (category (code "bar") " baz") (arguments "(" "x" " " (code "int") ")")))
- "@deffnx {@code{bar} baz} foo (x @code{int})
- ")
- )
|